fork(1) download
  1. #include <stdio.h>
  2. //課題3
  3. int rec(int n){
  4. //rec内を完成させてください
  5. if(n==0)return 3;
  6. else if(n==1)return 0;
  7. else if(n==2)return 2;
  8. else return rec(n-2)+rec(n-3);
  9. }
  10.  
  11. int main(void) {
  12. int n = 50;
  13. for(int i = 0; i <= n; i++){
  14. int tmp=rec(i);
  15. printf("%d, ",tmp%n);
  16. //if((tmp%n)==0) printf("%d, ", tmp);
  17. }
  18.  
  19. return 0;
  20. }
  21.  
  22.  
Success #stdin #stdout 0.02s 5316KB
stdin
Standard input is empty
stdout
3, 0, 2, 3, 2, 5, 5, 7, 10, 12, 17, 22, 29, 39, 1, 18, 40, 19, 8, 9, 27, 17, 36, 44, 3, 30, 47, 33, 27, 30, 10, 7, 40, 17, 47, 7, 14, 4, 21, 18, 25, 39, 43, 14, 32, 7, 46, 39, 3, 35, 42,