fork download
  1.  
  2. #include <stdio.h>
  3.  
  4. int rec(int n) {
  5. if (n == 0) return 3;
  6. else if (n == 1) return 0;
  7. else if (n == 2) return 2;
  8. return rec(n - 2) + rec(n - 3);
  9. }
  10.  
  11. int main(void) {
  12. for (int i = 0; i <= 50; i++) {
  13. printf("%d\n", rec(i));
  14. }
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.02s 5312KB
stdin
Standard input is empty
stdout
3
0
2
3
2
5
5
7
10
12
17
22
29
39
51
68
90
119
158
209
277
367
486
644
853
1130
1497
1983
2627
3480
4610
6107
8090
10717
14197
18807
24914
33004
43721
57918
76725
101639
134643
178364
236282
313007
414646
549289
727653
963935
1276942