Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int a=0,b=1,i,c,n,p,j,d[50],k=0;
- printf("Enter the number of terms:");
- scanf("%d",&n);
- printf("\n\nThe Fibonacci numbers are:\n\n%d %d ",a,b);
- for(i=0;i<n-2;i++)
- {
- c=a+b;
- printf("%d ",c);
- p=c;
- if(p>1)
- {
- for(j=2;j<=p/2;j++)
- {
- if(p%j==0)
- break;
- }
- if(j>p/2)
- {
- d[k]=p;
- k++;
- }
- }
- a=b;
- b=c;
- }
- printf("\n\nThe prime numbers of the fibonacci series are: ");
- for(j=0;j<k;j++)
- printf("%d, ",d[j]);
- getch( );
- }
Add Comment
Please, Sign In to add comment