0
Write the program to determine if a number entered from the keyboard is a prime number or not?
I need answer
3 odpowiedzi
+ 7
Here the logic in python...
https://www.programiz.com/python-programming/examples/prime-number
Happy learning :)
+ 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.
+ 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