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