+ 1
Write a program to check whether the given number is prime or not...! By a simple technique
If we want to check the given number is prime (ex 97) then no need to check all 97 numbers... Just by checking upto 10 is enough because nearest number of squareroot of 97 is 10...so if any number upto 10 does not divide 97 then the given number is prime
6 Respostas
+ 13
If I understood well, you want a program that not try to divide a number until itself less one before concluding that the number is prime.
According to your example 97, it is enough to try to divide it until 9 to conclude that 97 is a prime number (division from 10 to 96 is not needed).
I can add that also try to divide for a non prime number is useless, so in case of 97 is enough try to divide for 2, 3, 5 and 7 to say that 97 is a prime number.
I have a code that to this, it is not so simple since it will provide more info, but maybe can be useful.
https://code.sololearn.com/cnBDO3pmRV7U/#java
What you request is in createPrimeList.
I hope you like it.
+ 2
Bro once check the logic..... It is giving wrong output...
+ 1
example not helping
+ 1
I have edited the question to understand you more clearly.... Plzz post if you have any doubts....! Happy to help
0
https://code.sololearn.com/cAr2wKtGL796/?ref=app