Hi guys am new in the forum. I need help in compiling a program that gives the next prime number example if someone says 5 then the program will give the next prime number 7
This is what i have so far, but is not successful. I will appreciate any help. Thanks in advance
First of all format your code using the <> button so it's easier to read.
I'll lay out the general idea. Start at the input number + 2 (assuming the input number will always be prime, not sure from your description). Call a function called is_prime() that determines if the number is prime or not. If not, increment the input number by one and repeat the loop.
is_prime() will work like this. Set i = 2. While i * i < input, check if (input % i) ==0. If it does, then return false. If it doesn't then return true.