help with a program

Here is the question, I need help getting started on this please!

Write a program that asks the user for a number and then determines if the number is prime or not. This determination is done in a function called prime() that accepts an integer number and returns a result of prime or not. (Use a flag to do this). See appendix for how to determine if a number is prime and how to use flags. Here is the skeleton (pseudocode)

Setup your serial port in setup()

In the loop() function, ask the user for a number to check, N

Call the function prime() and pass to it the value of N. The function will return a flag that can be checked to see if N is prime or not

Inside the function, using a loop, check if N is prime

Do this by checking if N is divisible by any number from 2 to the square root of N.

Use the modulus (%) operator. If the remainder is zero, you found a factor and the number N is not prime.

Return a TRUE/FALSE flag value to the loop() function.

The IDE comes with documentation, available from the "help" tab. Have you consulted the appendix that was mentioned in your school assignment, as suggested? Have you looked at the example sketches that come with the IDE?

ashley108:
Here is the question, I need help getting started on this please!

You already have a huge amount of help to get you started.

Time to do some reading and some hard thinking, I suspect.
After all you have to do some work if you expect to earn marks for your project.

…R

Idea! Team up with a classmate. Discuss your problems.