fork download
  1. #include <stdio.h>
  2. int c = 0;
  3. int rec(int n) {
  4. if (n == 0)
  5. return 3;
  6. else if (n == 1)
  7. return 0;
  8. else if (n == 2)
  9. return 2;
  10. else
  11. return rec(n-2) + rec(n-3);
  12. }
  13. int main(void) {
  14. int n = 50;
  15. for (int i = 1; i <= n; i++) {
  16. if (rec(i) % i == 0) {
  17. c++;
  18. printf("%d, ", i);
  19. }
  20. }
  21. printf("\nカウント: %d\n", c);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.02s 5280KB
stdin
Standard input is empty
stdout
1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 
カウント: 16