blob: c7eb76ce64ba9c06d14818fd89456200d059752d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#print
Print the 20 Fibonacci numbers beginning with 2
(the sequence is 2,3,5,8,... where each number
is the sum of the immediately preceding pair of numbers.
Start with the pair 1,1).
Print each number on a separate line as a five digit
number (remember %3d in printf? %5d does five digits).
Compile and test your program; then type "ready".
#once #create Ref
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
#user
a.out >xxx
#cmp xxx Ref
#succeed
/* one way */
main()
{
int f1, f2, t, count;
f1 = 1;
f2 = 1;
for (count = 0; count < 20; count++) {
t = f1+f2;
f1 = f2;
f2 = t;
printf("%5d\n", t);
}
}
#log
#next
18.1a 10
|