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