fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. unsigned maxSteps=1;
  5. for (unsigned B=2; B<=8192; ++B) {
  6. for (unsigned A=1; A<B; ++A) {
  7. unsigned gcd=A;
  8. unsigned steps=0;
  9. for (unsigned r=B%gcd; r>0; gcd=r, r=B%gcd) {
  10. ++steps;
  11. }
  12. if (steps > maxSteps) {
  13. maxSteps = steps;
  14. }
  15. }
  16. if (!(B&(B-1))) {
  17. printf("%d - %d\n", B, maxSteps);
  18. }
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 1.5s 5308KB
stdin
Standard input is empty
stdout
2 - 1
4 - 1
8 - 2
16 - 4
32 - 5
64 - 8
128 - 10
256 - 12
512 - 14
1024 - 16
2048 - 18
4096 - 21
8192 - 25