fork download
  1. #include <stdio.h>
  2. //課題3
  3. int rec(int n){
  4.  
  5. if(n==0){
  6. return 3;}
  7.  
  8. else if(n==1){
  9. return 0;}
  10.  
  11. else if(n==2){
  12. return 2;}
  13.  
  14. else
  15. {
  16. return rec(n-2)+rec(n-3);
  17. }
  18. }
  19.  
  20. int main(void) {
  21. int n = 50;
  22. for(int i = 0; i <= n; i++){
  23. if(i!=0 && rec(i)%i==0){
  24. printf("%d, ", i);}
  25. }
  26.  
  27. return 0;
  28. }
  29.  
  30.  
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,