note 47856 added to language.operators.arithmetic

From: Date: Thu, 02 Dec 2004 21:15:27 +0000
Subject: note 47856 added to language.operators.arithmetic
Groups: php.notes 
Request: Send a blank email to php-notes+get-81297@lists.php.net to get a copy of this message
To factor a number: <?php function factornumber($number) { for ($i=1; $i<=($number/2); $i++) { if ($number % $i == 0) { echo "$i * ".($number/$i)." = $number\n"; } } } factornumber(50); ?> That script outputs: 1 * 50 = 50 2 * 25 = 50 5 * 10 = 50 10 * 5 = 50 25 * 2 = 50 As you may notice, it makes no attempts at removing duplicates (eg: 5*10 and 10*5), although it would be trivial to make it do so. ---- Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47856 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47856&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47856&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81297) next »