You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
358 B
PHTML
23 lines
358 B
PHTML
5 years ago
|
<?php
|
||
|
function is_Power($x, $y)
|
||
|
{
|
||
|
$a = $x;
|
||
|
$b = $y;
|
||
|
while ($x % $y == 0) {
|
||
|
$x = $x / $y;
|
||
|
}
|
||
|
|
||
|
if($x == 1)
|
||
|
{
|
||
|
return "$a is power of $b";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "$a is not power of $b";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
print_r(is_Power(16,2)."\n");
|
||
|
print_r(is_Power(12,2)."\n");
|
||
|
print_r(is_Power(81,3)."\n");
|
||
|
?>
|