note 108865 added to control-structures.continue

From: Date: Thu, 31 May 2012 07:20:55 +0000
Subject: note 108865 added to control-structures.continue
Groups: php.notes 
Request: Send a blank email to php-notes+get-188312@lists.php.net to get a copy of this message
/* Improvement to the previous example would be to only check if the number is divisible by less than half of its value (because a number 'x' can never be divisible by a number 'y' that is more than its half) */ <?php function print_primes_between($x,$y) { for($i=$x;$i<=$y;$i++) { for($j= 2; $j < ($i/2); $j++) if($i%$j==0) //Check divisibility less than only half of the number continue 2; if($i!=0 && $i!=1) //0&1 not included in prime numbers echo $i.","; } } echo print_primes_between(0,50); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 124.125.82.107 ---- Manual Page -- http://www.php.net/manual/en/control-structures.continue.php Edit -- https://master.php.net/note/edit/108865 Del: integrated -- https://master.php.net/note/delete/108865/integrated Del: useless -- https://master.php.net/note/delete/108865/useless Del: bad code -- https://master.php.net/note/delete/108865/bad+code Del: spam -- https://master.php.net/note/delete/108865/spam Del: non-english -- https://master.php.net/note/delete/108865/non-english Del: in docs -- https://master.php.net/note/delete/108865/in+docs Del: other reasons-- https://master.php.net/note/delete/108865 Reject -- https://master.php.net/note/reject/108865 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188312) next »