Where is the error in my Conditional Statement (PHP)? -


the challenge is:

  • if n odd, print "weird".
  • if n , in inclusive range of 2 5, print "not weird".
  • if n , in inclusive range of 6 20, print "weird".
  • if n , greater 20, print "not weird".

and code is:

<?php $n=5;  if($n%2==0 && $n>20){     echo "not weird"; }else{     echo "weird"; } ?>  

and problem is:

when rut locally it's okay. when submit hackerrank fails test when comes $n=5; case. have problems in conditional according challenge?

<?php $n=5; if($n%2==1){     echo 'weird'; }else{     if($n >= 2 && $n <= 5){         echo 'not weird';     }elseif($n > 5 && $n <= 20){         echo 'weird';     }else{         echo 'not weird';     } } ?>  

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -