Write a PHP program to check whether a given positive integer is a power of four
- برمجة بي اتش بي
- 2021-09-10
- mhanasmh00489829403
الأجوبة
<?php
function is_Power_of_four($n)
{
$x = $n;
while ($x % 4 == 0) {
$x /= 4;
}
if($x == 1)
{
return "$n is power of 4";
}
else
{
return "$n is not power of 4";
}
}
print_r(is_Power_of_four(4)."\n");
print_r(is_Power_of_four(36)."\n");
print_r(is_Power_of_four(16)."\n");
?>
Sample Output:
4 is power of 4 36 is not power of 4 16 is power of 4
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال