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