week 1 problem set

 1 # include 
 2 int choose(int n);
 3 int main()
 4 {
 5     int i=2,a=1,b=1,c=2;
 6     printf("%d\n%d\n",a,b);
 7     for (i=2;i<=10;i++)
 8     {
 9         c=a+b;
10         a=b;
11         b=c;
12         printf("%d\n",c);
13         choose(c);
14     }
15     return 0;
16 }
17 
18 int choose(int n)
19 {
20     while(n!=1)
21     {
22         if(n%2==0)
23         {
24             printf("%d\n",n);
25             n=n/2;
26         }
27         else
28         {
29             printf("%d\n",n);
30             n=3*n+1;
31         }
32     }
33     return 0;
34 }

 

你可能感兴趣的:(week 1 problem set)