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