PHP Online Compiler
Example: Find LCM of Two Numbers in PHP using While loop
C
C++
C#
Java
Python
PHP
main.php
STDIN
Run
<?php // Find LCM of Two Numbers in PHP using While loop $p = 175; $q = 165; $x = 0; // $p & $q - To store the two positive numbers // $x - To store the LCM number $x = $p > $q ? $p : $q; while (1) { if ($x % $p == 0 && $x % $q == 0) { echo "The LCM of the {$p} and {$q} numbers is {$x}."; break; } ++$x; } ?>
Output
Clear
ADVERTISEMENTS