help with functional definition in c

help with functional definition in c

Page 1 of 1

2 Replies - 804 Views - Last Post: 19 February 2008 - 11:21 AM Rate Topic: -----

#1 ladiesman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 55
  • View blog
  • 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: :code:
Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 mac0sWizard  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • 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)
{
	//Your code here...
}




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

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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1