Friday 25 July 2014

program to generate the first 20 terms of the facobian series by using recursion .

#include<iostream>
using namespace std;
int facob(int );
int main()
{
int i;
for(i=1;i<=20;i++)
cout<<facob(i)<<" ";
}

int facob(int i)
{
if(i==1)
return(0);
else if(i==2)
return(1);
else
return(facob(i-2)+facob(i-1));
}

No comments:

Post a Comment

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...