Created
November 30, 2013 18:01
-
-
Save llelf/7722337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int result_c (int max_a0, int *max_len_r, int *longest_r) { | |
int longest = 0, max_len = 0; | |
int a0, len; | |
unsigned long a; | |
for (a0 = 1; a0 <= max_a0; a0++) { | |
a = a0; | |
len = 0; | |
while (a != 1) { | |
len++; | |
a = ((a%2==0)? a : 3*a+1)/2; | |
} | |
if (len > max_len) { | |
max_len = len; | |
longest = a0; | |
} | |
} | |
*max_len_r = max_len; | |
*longest_r = longest; | |
/* printf("(%d, %d)\n", max_len, longest); */ | |
return longest; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment