AcEBALL23 Posted October 22, 2012 Share Posted October 22, 2012 I keep on getting errors after errors i tried to research this but i coudn't find anything plz help here is my code: for($num=1; $num<=50; $num++){ $prime=true;$num=16; for($divisor=2;$divisor<$num;$divisor++){ if($num%divisor0) { $prime=false; break; } } $prime=true; if($prime&($num!=1) echo"$num\"<br>; } Quote Link to comment Share on other sites More sharing options...
requinix Posted October 22, 2012 Share Posted October 22, 2012 (edited) What errors? Parse error, unexpected T_ECHO? Unexpected $end? Unexpected ">"? Undefined constants "divisor0" or "br"? Edited October 22, 2012 by requinix Quote Link to comment Share on other sites More sharing options...
AcEBALL23 Posted October 22, 2012 Author Share Posted October 22, 2012 The "write php code online" website told me to write "divisor0" i wrote "divisor=0" Quote Link to comment Share on other sites More sharing options...
computermax2328 Posted October 23, 2012 Share Posted October 23, 2012 if($num%divisor0) { $prime=false; break; } In your first if statement divisor is not set as a variable. Should be $divisor. Idk what the 0 is for. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 23, 2012 Share Posted October 23, 2012 If you don't understand $num%$divisor==0, look up modulus. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 23, 2012 Share Posted October 23, 2012 What errors? Parse error, unexpected T_ECHO? Probably, considering that's what the title says. Shows how much attention I pay to those things. At the end there's an if block that's missing a closing ) and the on the line below has to be inside the quotes (which aren't terminated either, thanks to the extraneous backslash). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.