Question: This is done in the C language. can anyone explain to me step by step how this code works? This is a recursive function that
This is done in the C language.
can anyone explain to me step by step how this code works?
This is a recursive function that prints our nth prime number.
int findNthPrime(int n) { if(n == 1) return 2; int temp = findNthPrime(n - 1); int i = temp + 1; for(; ; i++) { int j = 2, prime = 1; for(; j <= i / 2; ++j) if(i % j == 0) prime = 0; if(prime == 1) return i; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
