What is the most efficient code for computing prime numbers in C and why is it the following?

What is the most efficient code for computing prime numbers in C and why is it the following?

void factorial(int n)
{
while(n>1){
if(n%2==0){
return factorial(n-1);
}
printf("Prime number: %d.\n",n);
return factorial(n-1);
}
return;
}
int main()
{
int n;
printf("Enter number\n");
scanf("%d",&n);
factorial(n);
}

Attached: pepe.jpg (800x331, 67K)

int main()
{
int n = 315;
primeFactors(n);
return 0;
}

>primeFactors

uuh sweetie you are missing something

just use miller rabin

Oh sorry. u gay }
}

>running time is O(k log3n)

k ought to be small though, and log^3n is still polynomial.

9 is not a prime number

lol

The fastest would be to just dump a precomputed table of primes up to the number you want. We know all primes in the 64 bit integer range anyway.

Things get more interesting when your numbers are so big that they don't fit on conventional variables though. Can you devise a fast algorithm for computing primes up to arbitrarily large numbers?

I thought recursive factorial was inefficient

#include

main(argc){
return isprime(argc);
}

Attached: whichoneofthesementalilnessesissooooyouonaweekday.jpg (450x600, 48K)

>We know all primes in the 64 bit integer range anyway
Storing a table of them would take terabytes.

Pajeet, you failed and failed hard.

Attached: pajeet.jpg (640x660, 67K)

i just fucking told you
mille rraniinmbnbin

Go home OP, you are drunk.

I sense that curry is strong in this one.

no it wouldn't

Breath in.
Breathe out.
Kys

I know that you pajeets don't know that, but in the IT world there's something called "testing your code"

I know it can be a hard concept for you to understand, but I highly recommend learning this

9 is not a prime number tho

>15 is a prime number

#include

using namespace std;

bool isPrime(int n)
{
if(n==2)
return true;
if(n % 2 == 0)
return false;

int i = 3;
while(i > a;
cout