Pages

Monday, October 5, 2009

UVA Problem#100

Question:

Solution:
1. take input i, j. let x=i, y=j. 
2. Generate the series.
for(a=i; a<=j; a++){ 
n=a; 
count=1; 
while(n!=1){
if(n%2==0){ 
n = n/2; 
}
else{ 
n = 3*n+1; 
count++; 
}  

3. find the max count value by 
if(maxcount < count){ 
maxcount=count; 

1 comment: