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