Get the App
SLTechnology News&Howtos  ›  Development  › 

How to output primes in a given range by php

Shulou Source: shulou.com Published: 2022-06-03 17:27:27 11月13日 Update

This article is about how php can output primes in a given range. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Description

1. On the basis of for cycle, a layer of for loop is set on the outside to control the range.

2. In the inner body of the for loop, use the counter $count to increment 1 after each prime output, so that you can count the number of primes within 1100.

Example

Thank you for reading! This is the end of this article on "how php can output primes in a given range". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Prime loop range output content more article good practical basic example loop body article look knowledge counter reference help control related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker MySQL OPPO Reno Redmi