0
How to write program detecting if the input is prime it order to insert another to testing . the program stop when ensert 0
2 odpowiedzi
0
What do you mean by prime? Is it prime numbers you are referring to? If that's the case then you can use the modulus operator to determine if the number is a prime. Remember a modulus operator returns remainder of the divided number. If the operator returns 0 that's means it's not prime but if it returns any other number then it's a prime. For example, 5%2 = 1 this has a remainder so it's a prime. However there is a special case here. 2 is a prime, so you need to check if the number is 2 every time. you can use a while for this
0
I have already done it, but i couldn't insert a good condition which ditects all case