ok this is my code so far i have to use " isprime" to calculate prime number how do i do thatand where do i put it.thank you

#include<stdio.h>
main()
{
static int n=0, number=1; // static: so value is not lost
int fibi (int n, int number);
printf ("Following are the first 25 Numbers of the Fibonacci Series:\n");
printf ("1 "); //to avoid complexity
fib (n,number);
}
fib (int n, int number)
{
static int i=1; //i is not 0, cuz 1 is already counted in main. 
int fibo;
if (i==40)
{
printf ("\ndone"); //stop after 25 numbers
}
else 
{
fibo=n+number;
n=number; //important steps
number=fibo; 
printf ("\n%d", fibo);
i++; // increment counter 
fib (n,number); //recursion
}
}

Don't make it so darn complicated. Here's a basic Fibonacci function that will never end:

void fib (int num1, int num2)
{
   num1 += num2;
   fib (num2, num1);
}

The rest is up to you.

Thanks I was having the same problem.

<< fake sig snipped >>

You check for Prime right after this line: printf ("\n%d", fibo); Did you start with the Isprime function? If so: show some code.

Another question: is recursion a requirement for your assignment?

Niek

umm no it just wanted to do a fibonacci series using prime

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.