answersLogoWhite

0

The easiest, but not the most efficient way, to program this is to take your number "n" and test all the numbers from 2 to n-1 to see if they divide n, if none of them do, then n is prime.

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
ReneRene
Change my mind. I dare you.
Chat with Rene
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan

Add your answer:

Earn +20 pts
Q: How do you program if it is a prime or composite?
Write your answer...
Submit
Still have questions?
magnify glass
imp