/*Program to print prime numbers*/
/*From N fibnocci series*/
#include<stdio.h>
int main()
{
int i, j, count, n, t1=0, t2=1, t3;
printf("Enter the number of terms:\n");
scanf("%d",&n);
printf("The prime numbers that are in %d fibnocci series are:\n",n);
for(i=1; i<n; i++)
/*In this I have used i<n but not i <= n because I'm starting fibnocci series from 1, 1, 2, 3, 5, 8.... */
{
t3 = t1+t2;
t1 = t2;
t2 = t3;
count = 0;
for(j=1; j<=t1; j++)
{
if(t1%j == 0)
count++;
}
if(count == 2)
printf("%d\n",t1);
}
}
Output::
Enter the number of terms:
15
The prime numbers that are in 10 fibnocci series are:
2
3
5
13
89
233
0 Comments