+ 1

How to print prime number on java

Prime Number

17th Dec 2018, 4:20 PM
Abdul Aziz
2 odpowiedzi
+ 15
Hy Abdul Aziz ● a Prime number is divisible by 1 & number itself. ● so, U just need to run a loop from 2 to number-1 & checking divisibility of number in each iteration [if get divisible,then change some value of variable k(from 0 to 1) taken outside loop for identifying prime or not & then break; through loop] ● after loop, check value of k, if its 0 then prime, else non-prime. //U can share your code to get community help.👍 //U can run loop from 2 to sqrt(number) for more efficiency
17th Dec 2018, 5:14 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
Hi Abdul Aziz, If you have a difficulty to create a prime number, do not hesitate to talk to a programmers from Sololearn using Sololearn Messenger.
17th Dec 2018, 6:16 PM
program
program - avatar