0
How to make flow chart algorithm for identification of prime and composite number
.... by ascending order
1 ответ
0
In programming, there’s a neat trick to find all the prime numbers.
here’s some pseudo code:
while(num < howmantocheck)
round = math.round(num)
round = math.floor(round)
if(num != 1)
for(x = 1 x <= round x++)
if(x != 1)
if(num % x == 0)
nonprime += 1
else
nonprime = 1
if(nonprime == 0)
print(num)
nonprime = 0
num++
There’s probably better and more compact ways to do it but am a little sick today but it should work,
an example in C#:
https://hastebin.com/hacuvateta.cs
Hope this helps.