note 33964 deleted from control-structures.for by irchtml

From: Date: Fri, 04 Jun 2004 05:52:46 +0000
Subject: note 33964 deleted from control-structures.for by irchtml
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70629@lists.php.net to get a copy of this message
Note Submitter: aehmc@mixmail.com ---- for ($n=5;$n<=100;$n++){ for ($m=2;$m<=$n-1;$m++){ if ($n%$m==0){ $primo=false; break; }else{ $primo=true; } } if ($primo==false){ print "EL NUMERO: ".$n." NO ES PRIMO<br>"; }else{ print "EL NUMERO: ".$n." ES PRIMO<br>"; } } el bucle ademas de romperlo con break tambien podemos romperlo haciendo que la variable contadora incumpla la condicion for ($i=1;$i<=10;$i++){ print $i."<br>"; if ($i==5) $i=11; }

« previous php.notes (#70629) next »