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 -6*rec(n-2)-9*rec(n-3);
  16. }
  17. }
  18.  
  19. int main(void) {
  20. int n = 50;
  21. for(int i = 0; i <= n; i++){
  22. printf("%d, ", rec(i));
  23. }
  24.  
  25. return 0;
  26. }
  27.  
  28.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
3, 0, 2, -27, -12, 144, 315, -756, -3186, 1701, 25920, 18468, -170829, -344088, 858762, 3601989, -2055780, -29340792, -20083221, 194546772, 384566454, -986531643, 236647624, -1836875524, -1131035549, 301489936, 1843256530, -219554267, -888046716, 1907886016, -1285665893, 840071644, -867044194, -2059371419, 1936587664, -1315210220, -1675117805, -948093064, 412762330, -710217851, 1761296300, 546446136, 119150155, -1950474332, -1337948858, 2040560005, -187841640, -201820308, -58121021, -1393470688, -2129858398,