0

Write the program to determine if a number entered from the keyboard is a prime number or not?

I need answer

29th Jun 2019, 6:43 PM
Mohammed Hussaini Musa
3 odpowiedzi
29th Jun 2019, 7:30 PM
Sujithra
+ 3
I hate that project. In program to test if x is prime, you should test all WHOLE NUMBERS between 2 and √x, and test x's divibility by their modulo. If any of modulos returned 0, x is not a prime number. Otherwise it is a prime number. But in maths, to test if x is prime you need only test all the PRIMES between 2 and √x, and .... The thing I mainly hate, is that using the second method would take longer in programs, than the first method, because you should also test, whether all numbers between 2 and √x are also primes. Getting all primes between 2 and 1000 would take a minute with the second method, while with the first method it would only take a second.
29th Jun 2019, 7:55 PM
Seb TheS
Seb TheS - avatar
+ 1
Please, do not ask for full code. Try searching on Google for how to start. On Python you can use input() for this. On C scanf, getch, etc
29th Jun 2019, 6:48 PM
Alexander Santos
Alexander Santos - avatar