Theerayut

Factnum

Dec 9th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include<stdio.h>
  2. int fact(int num);
  3. int main()
  4. {
  5.     int n,b;
  6.     printf("N : ");
  7.     scanf("%d",&n);
  8.     b=fact(n);
  9.     printf("Sum = %d",b);
  10.     return 0;
  11. }
  12.  
  13. int fact(int num)
  14. {
  15.     if(num==0||num==1)
  16.     return 1;
  17.     else
  18.     return 4+fact(num-1)+fact(num-2);
  19. }
Add Comment
Please, Sign In to add comment