# help with functional definition in c

Page 1 of 1

## 2 Replies - 885 Views - Last Post: 19 February 2008 - 11:21 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=43738&amp;s=d2b4a2ba424a8af358729b73a3b6c8a7&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

• New D.I.C Head

Reputation: 0
• Posts: 35
• Joined: 09-February 08

# help with functional definition in c

Posted 19 February 2008 - 11:03 AM

can anyone help me using c please?

Write functions to:
int isprime(int); /* Returns a true value if a is a prime number */
int nextFib(); /* Returns the next fibonacci value (use static variables to track which one was used last call) */
The fibonacci sequence is defined as:
Fib(0)=1

Fib(1)=1

Fib(2)=Fib(1)+Fib(0)

....

Fib(N)=Fib(N-1)+Fib(N-2)

Write a main program which will call nextFib 40 times and the check to see whether the each fibonacci number is prime using isprime.
Your program will then report the sequence number, the fibonacci value, and whether or not the number is prime.

This post has been edited by ladiesman: 19 February 2008 - 11:04 AM

Is This A Good Question/Topic? 0

## Replies To: help with functional definition in c

### #2 PennyBoki

• D.I.C Lover

Reputation: 55
• Posts: 2,345
• Joined: 11-December 06

## Re: help with functional definition in c

Posted 19 February 2008 - 11:09 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this:
Thanks.

### #3 mac0sWizard

• New D.I.C Head

Reputation: 0
• Posts: 18
• Joined: 18-February 08

## Re: help with functional definition in c

Posted 19 February 2008 - 11:21 AM

for the primes, it is only a couple of lines.

```
bool IsPrime (int num)
{
}

```

as for the fib...
my advice -> use recursion

This post has been edited by mac0sWizard: 19 February 2008 - 11:29 AM