求助一道计算机算法题Write an algorithm which asks the user to enter a

求助一道计算机算法题
Write an algorithm which asks the user to enter a number and the program will print
either (a) “the number is a prime number” if the number entered is a prime number or (b)
“the number is not a prime number” if the number entered is not a prime number.
A prime number (or a prime) is a natural number greater than 1 that has no positive
divisors other than 1 and itself.For example,these numbers are all prime numbers:2,3,
5,7,11,13,17,19; however,these numbers are not prime numbers:1,4,6,8,9,10,12,
14,15,16,18.
smueeq 1年前 已收到1个回答 举报

顽皮海豚 幼苗

共回答了14个问题采纳率:85.7% 举报

step1 input a number to n
step2 set i=2
step3 if n can be divisible by i, then print "the number is not a prime number" and
go to step,else go to step4
step4 set i=i+1
step5 if i is not less than n, then print "the number is a prime number" and go to
step6, else go to step3
step6 end of algorithm

1年前

10
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.022 s. - webmaster@yulucn.com