Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int fib (int n)
- {
- if(n==1||n==2)
- {
- return 1;
- }
- else
- {
- return(fib(n-1)+fib(n-2));
- }
- }
- int main(void)
- {
- int n;
- printf("Enter the Number to find its fibionacci Series \n");
- scanf("%d",&n);
- printf("The %d term is %d \n",n,fib(n));
- int i;
- printf("The series is \n");
- for(i=1;i<=n;i++){
- printf("%d",fib(i));
- if (i<n){
- printf(",");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment