Write a function with the prototype unsigned long findFibonacciPrimes(unsigned long lowerBound, unsigned long upperBound, unsigned long result[]) which populates the array result with all of the prime numbers that are also Fibonacci numbers between lowerBound (inclusive) and upperBound (inclusive), and then returns the number of Fibonacci primes that were found.
A prime number is any number that has only two integer divisors, itself and 1. For example, the number 13 is prime, because its only integer divisors are 1 and 13 (1 x 13 = 13). However, the number 9 is not prime, because it has three integer divisors: 1, 3 and 9 (1 x 9 = 9 and 3 x 3 = 9).
A Fibonacci number is one that follows the following rules:
The first Fibonacci number is 0
The second Fibonacci number is 1
Every Fibonacci number above this can be calculated as the sum of the previous two Fibonacci numbers
The first ten Fibonacci numbers are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34...
The array result is guaranteed to have enough space to store all the numbers found. Your program will crash if it attempts to write past the end of the array, and no marks will be awarded for any tests this occurs in. You are also guaranteed that 1 < lowerBound < upperBound < 3,000,000,000.
aaronzf 0 Newbie Poster
daviddoria 334 Posting Virtuoso Featured Poster
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.