i think i ve solved it, it gives me correct answers, but when i try to submit, it says wrong answer.
is there something wrong with my code?
Code:
#include <stdio.h>
int main() {
unsigned long i,x,y,k,max,s,temp;
while (scanf("%lu %lu",&x,&y)!=EOF){
if (x>y){
temp=y;
y=x;
x=temp;
}
max=1;
for (i=x;i<=y;i++){
s=function(i,1);
if (s>max){
max=s;
}
}
printf("%lu %lu %lu",x,y,max);
}
return 0;
}
function(unsigned long n, unsigned long m) {
while (n!=1){
if (n%2==1){
n=n*3+1;
m++;
}
else {
n=n/2;
m++;
}
}
return m;
}
thanks