fork download
  1. #include <stdio.h>
  2.  
  3. int c = 0;
  4.  
  5. // rec関数の定義
  6. int rec(int n) {
  7.  
  8. if (n == 0) {
  9. return 3;
  10. } else if (n == 1) {
  11. return 0;
  12. } else if (n == 2) {
  13. return 2;
  14. } else {
  15.  
  16. return rec(n - 2) + rec(n - 3);
  17. }
  18. }
  19.  
  20. int main(void) {
  21. int n = 50;
  22.  
  23. for (int i = 1; i <= n; i++) {
  24. int value = rec(i);
  25. if (value % i == 0) {
  26. c++;
  27. }
  28. }
  29.  
  30.  
  31. printf("Total count of n where a(n) is divisible by n: %d\n", c);
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Total count of n where a(n) is divisible by n: 16