programming-examples/php/Basics/PHP program to check if a given positive integer is a power of two..php
2019-11-18 14:44:36 +01:00

16 lines
282 B
PHP

<?php
function is_Power_of_two($n)
{
if(($n & ($n - 1)) == 0)
{
return "$n is power of 2";
}
else
{
return "$n is not power of 2";
}
}
print_r(is_Power_of_two(4)."\n");
print_r(is_Power_of_two(36)."\n");
print_r(is_Power_of_two(16)."\n");
?>