- #1

Arman777

Gold Member

- 1,785

- 139

**1. The problem statement, all variables, and given/known data**

Create algorithm steps that for a given number (N) is prime or not

## Homework Equations

3. The Attempt at a Solution

3. The Attempt at a Solution

I am trying to create an algorithm but I am stuck at some place.

Here is my trying.

1-Input a non-negative integer N

2-If N=2 go step n

3-If N>2 go to step 4

4-Calculate N\2

5-If Remaining number of N\2=0 go step m, otherwise, go 6

6-Calculate N\3

7- If remaining number N\3=0 go step m, otherwise go step 8-

8-Calculate N\4

9- If remaining number 0 go step m, otherwise go step 10.

10-Calculate N\5

11-If remaining number 0 go to step m, otherwise, go to step

Now step "m" will represent false (not a prime number) and step "n" will represent true (its a prime number). I want to stop this when N=N but I am not sure how to write it..Or this method is valid?

I can do this until N\N and If it comes until N (The last step), then I ll say its prime.

Thanks

Last edited: