fork download
  1. #include <stdio.h>
  2.  
  3. int c;
  4.  
  5. int rec (int n){
  6. c++;
  7.  
  8. if(n==1){
  9. return 1;
  10. }
  11. else if (n==2){
  12. return 2;
  13. }
  14. else{
  15. return -6*rec(n-1)-9*rec(n-2);
  16. }
  17.  
  18. }
  19.  
  20. int main(void) {
  21. int n=4;
  22. printf("数列a%dの値は%d\n",n,rec(n));
  23. printf("このときrecの呼び出し回数は%d",c);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
数列a4の値は108
このときrecの呼び出し回数は5