+ 1

what's wrong with code? ain't working on playground.code in the comment

https://code.sololearn.com/wkx1Ztri2kBt/?ref=app

22nd May 2017, 6:12 PM
Isomer
Isomer - avatar
3 Antworten
+ 4
Please save this code on the playground and post the link to the code in your question. It's easier to work with it like that.
22nd May 2017, 6:40 PM
Tim G
Tim G - avatar
0
<?php if(is_numeric($_GET['number']) && $_GET['number'] > 0 && $_GET['number'] == round($_GET['number'], 0)){ $i = 2; $isPrime = true; while ($i < $_GET['number']) { if ($_GET['number'] % $i == 0) { // Number is not prime! $isPrime = false; } $i++; } if ($isPrime) { echo "<p>".$i." is a prime number!</p>"; } else { echo "<p>".$i." is not prime.</p>"; } } else if ($_GET) { // User has submitted something which is not a positive whole number echo "<p>Please enter a positive whole number.</p>"; } ?> <p>Please enter a whole number.</p> <form> <input name="number" type="text"> <input type="submit" value="Go!"> </form>
22nd May 2017, 6:15 PM
Isomer
Isomer - avatar