because im pretty sure my isprime function wouldn't be able to calculate large numbers like 1.92749293503
I'm very sure that your isprime function won't be able to calculate primes at all. Unless you're confused as to what a prime is. The primes lower than 10 are 2, 3, 5, and 7. Let's run the equivalent of your code through all positive numbers less than 10:
Code:
#include <iostream>
using namespace std;
bool isprime(int num)
{
return num % 2 == 0;
}
int main()
{
for (int x = 1; x < 10; x++) {
if (isprime(x))
cout << x << endl;
}
return 0;
}
isprime() failed to find all but one of the primes because isprime() doesn't test for primality, it tests for divisibility by 2. A prime number is a number that is only evenly divisible by itself and 1, which rules out most of the even numbers. That makes your isprime() horribly broken if you think it finds primes. A simple test for primality is slightly more difficult than just testing divisibility by 2, but it's dreadfully slow for larger numbers:
Code:
bool isprime(int num)
{
if (num < 2) return 0;
for (int x = num - 1; x > 1; x--) {
if (num % x == 0) return false;
}
return true;
}