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

TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
JudyJudy
Simplicity is my specialty.
Chat with Judy
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
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

2mo 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