note 105057 modified in control-structures.continue by danbrown
| From: | danbrown@php.net | Date: | Mon, 25 Jul 2011 16:23:55 +0000 |
| Subject: | note 105057 modified in control-structures.continue by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181858@lists.php.net to get a copy of this message | ||
<?php
function print_primes_between($x,$y)
{
for($i=$x;$i<=$y;$i++)
{
for($j= 2; $j < $i; $j++) if($i%$j==0) continue 2;
echo $i.",";
}
}
?>
This function, using continue syntax, is to print prime numbers between given numbers, x and y.
For example, print_primes_between(10,20) will output:
11,13,17,19,23,29,
--was--
function print_primes_between($x,$y)
{
for($i=$x;$i<=$y;$i++)
{
for($j= 2; $j < $i; $j++) if($i%$j==0) continue 2;
echo $i.",";
}
}
This function, using continue syntax, is to print prime numbers between given numbers, x and y.
For example, print_primes_between(10,20) will output:
11,13,17,19,23,29,
http://php.net/manual/en/control-structures.continue.php