Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

DZone's Guide to

# Step-by-step Logic Finding Prime numbers with PHP

· Web Dev Zone ·
Free Resource

Comment (0)

Save
{{ articles[0].views | formatCount}} Views

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

A Prime numbers are all integers(number) that can be divided evenly only by 1 AND itself.
And it must be a whole number greater than 1.

2           3
/   \        /  \     ...................
1   2      1  3

Logic in Program

Take a look above, the green numbers indicate that each prime number has exactly 2 (two) divisors. 1 and itself. From this simple logic, we can easily code it . Take a look again in Snippet above

Notes: This example is just for those who are new to this
```function prime(\$n){

//all numbers that will be evaluated as prime
for(\$i=1;\$i";
}
}
}

prime(20);  //find the Prime for 1-20 range```

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:
php

Comment (0)

Save
{{ articles[0].views | formatCount}} Views

Opinions expressed by DZone contributors are their own.

# {{ parent.title || parent.header.title}}

### {{ parent.tldr }}

{{ parent.urlSource.name }}