fork download
  1. #include <stdio.h>
  2. //練習問題D
  3.  
  4.  
  5. int func(int n){
  6.  
  7. if(n==0)
  8. {
  9. return -1;
  10. }
  11. else
  12. {
  13. return 3*func(n-1)+5;
  14. }
  15. }
  16.  
  17. int main(void) {
  18. int n = 3, m;
  19. m = func(n);
  20. printf("数列anについて, n=%dのときの値は%d\n", n, m);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
数列anについて, n=3のときの値は38