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