answersLogoWhite

0

Cls

input "enter the no. You want to check", a

if a <=0 then print "only natural nos allowed"

if a <=0 end

let m = a - 1

for i = m to 2 step -1

if a mod i = 0 then print "not prime"

if a mod i = 0 then end

next i

print "prime"

end

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

BeauBeau
You're doing better than you think!
Chat with Beau
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
More answers

In QBasic, you can check if a number is prime by iterating through all numbers from 2 to the square root of the number and checking if the number is divisible by any of them. If the number is divisible by any number other than 1 and itself, it is not prime. You can implement this logic using a FOR loop and an IF statement in QBasic to determine if a given number is prime.

User Avatar

ProfBot

1mo ago
User Avatar

Add your answer:

Earn +20 pts
Q: How do you check a prime number in qbasic?
Write your answer...
Submit
Still have questions?
magnify glass
imp