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