You are viewing a single comment's thread from:

RE: Java program -5: Write a program which show the display of 15 prime number.

in #java7 years ago

It’s a good post, but you could be more thoughtful on the inner loop. You could use a step-size of at least 2. Or if the number is larger than 3, print 3 and use a step-size of 3. Cause the primes cannot be any multiples of those numbers. In fact you just have to check if they are divisible by smaller prime numbers. If not, it is a new prime. That’s a much more efficient way. But your way is also okay for little numbers.

Coin Marketplace

STEEM 0.19
TRX 0.16
JST 0.033
BTC 64261.31
ETH 2787.80
USDT 1.00
SBD 2.66