fork download
  1. #include <stdio.h>
  2. //課題3
  3. int rec(int n){
  4. //rec内を完成させてください
  5. if (n==0){
  6. return 3;
  7. }else if(n==1){
  8. return 0;
  9. }else if(n==2){
  10. return 2;
  11. }else{
  12. return rec(n-2)+rec(n-3);
  13. }
  14. }
  15.  
  16. int main(void) {
  17. int n = 50;
  18. for(int i = 1; i <= n; i++){
  19. if(rec(i)%i==0)
  20. printf("[%d]%d\n", i,rec(i));
  21. }
  22.  
  23. return 0;
  24. }
  25.  
  26.  
Success #stdin #stdout 0.03s 5272KB
stdin
Standard input is empty
stdout
[1]0
[2]2
[3]3
[5]5
[7]7
[11]22
[13]39
[17]119
[19]209
[23]644
[29]3480
[31]6107
[37]33004
[41]101639
[43]178364
[47]549289