<?php if(isset($_POST['submit'])){ $number= $_POST['number']; $ar=(explode(" ",$number)); $no= count($ar); $n=0; $num=2; $lcm=1; while($n!=$no){ $flag=0; $n=0; for($i=0;$i<$no;$i++){ if($ar[$i]==1){ $n++; } if($ar[$i]%$num==0){ $ar[$i]=$ar[$i]/$num; $flag=1; } } if($flag==1){ $lcm= $lcm*$num; } else{ $num++; } } echo "The LCM of all the Number is ".$lcm; } ?> <html> <head> <title>LCM</title> </head> <body> <form action="" method='POST'> <label for="number">Please Enter No</label> <input type="text" name="number" value=""> <br><br> <input type="submit" value="Done" name="submit"> </form> </body> </html>
Stay tuned for the PHP Magento, WordPress and Magento2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento Development / PHP we can help you, just Click on the Link and send me your requirements.
Please Like the Post on Facebook or Google+.