fork download
  1. #include <stdio.h>
  2. //課題3
  3. int rec(int n){
  4. //rec内を完成させてください
  5. if(n==0)return 3;
  6. if(n==1)return 0;
  7. if(n==2)return 2;
  8. return rec(n-2)+rec(n-3);
  9. }
  10.  
  11. int main(void) {
  12. int n = 50;
  13. for(int i = 1; i <= n; i++){
  14. if(rec(i)%i==0)
  15. printf("[%d]%d, ", i,rec(i));
  16. }
  17.  
  18. return 0;
  19. }
  20.  
  21.  
Success #stdin #stdout 0.02s 5312KB
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,