Post Top Ad

Your Ad Spot

Pages

Monday, 10 February 2020

COMBINATION OF FIBONACCI AND PRIME NUMBER SERISE

#include<stdio.h>
 //NO IS PRIME OR NOT
int Isprime(int no)
{
int i;
for(i=2;i<=no/2;i++)
{
if(no%i==0)
return 0;
}
return 1;
}

int Nthprime(int n)
{
int i;

int count=0;
for(i=2;count<n;i++)
{

if(Isprime(i))
{   count++;

    }
}
return i-1;
}

int Fibonacci(int n)
{
   int i,a=1,b=1,c,count=0;
for(i=1;count<n;i++)
{
c=a+b;
a=b;
b=c;
count++;
}
return a;
  }
  
  void tcs(int no)
  {
int i;
     for(i=1;i<no;i++)
     {
printf(" %d ",Nthprime(i));
printf(" %d ",Fibonacci(i));
 
}  
  }

void main()
{
tcs(30);
}

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages