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