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 return tri(n - 1) + tri(n - 2) + tri(n - 3);
  8. }
  9.  
  10. int main(void) {
  11. int n = 7;
  12. printf("数列Tnについて, n=%dのときの値は%d\n", n, tri(n));
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
数列Tnについて, n=7のときの値は13