fork download
  1. #include <stdio.h>
  2. static int count=0;
  3. int funk(){
  4.  
  5. count++;
  6. return count;
  7. }
  8. int rec(int n){
  9.  
  10. if(n==1){
  11. funk();
  12. return 1;
  13. }
  14. else if(n==2){
  15. funk();
  16. return 2;
  17. }
  18. else{
  19. funk();
  20. return -6*rec(n-1)-9*rec(n-2);
  21. }
  22. }
  23.  
  24. int main(){
  25.  
  26. int n=5;
  27. printf("数列a%dの値は%d",n,rec(n));
  28. printf("呼び出しの回数は%d",count);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
数列a5の値は-459呼び出しの回数は9