In this assignment the user gives a positive integer, and from that integer the program should determine whether it is prime or not, and then give all the values between 1 and nth (user interger) term that are prime.
I need help on figuring out what is wrong with my code. If the value can be divided by 3, it is considered prime. I can't figure out how to fix it. Here is what I have so far...
#include <iostream>
using namespace std;
bool isPrime (int number);
void findPrimes (int n);
unsigned long long int fibo (int n);
void findPrimeFactors (int number);
int main ()
{
int testNum;
// test for the isPrime function
cout << "Enter a test number - ";
cin >> testNum;
cout << endl;
if( isPrime(testNum) )
cout << testNum << " is prime." << endl;
else
cout << testNum << " is not prime." << endl;
// test for how many primes
cout << "The prime numbers between 1 and "<< testNum << " are: " << endl;
findPrimes( testNum );
cout << endl;
// test for Fibonacci number finder
cout << "The Fibonacci number for " << testNum << " is : " << fibo( testNum ) << endl;
//test for prime factors
cout << "The prime factors of " << testNum << " are: " << endl;
Thank you sooooo much! That worked. Now all I need to do is figure out the Fibonacci part and I can finally turn it in (hopefully I can do that just fine). Thanks a bunch!