Your Ad Here

Posted By

adkatrit on 07/24/10


Tagged

square perfect


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

osirisinternet
mgerdt
adkatrit


perfect square function


 / Published in: PHP
 

  1. <?php
  2. function is_perfect($num){
  3. $isPerf=false;
  4. if(sqrt($num)-floor(sqrt($num))==0)
  5. $isPerf=true;
  6. return $isPerf;
  7. }
  8. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: adkatrit on November 9, 2011

one liner version:

$is_perf = (sqrt($num)-float(sqrt($num))==0) ? true:false;

You need to login to post a comment.