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