1--TEST--
2gmp_perfect_power(): Check if number is a perfect power
3--SKIPIF--
4<?php if (!extension_loaded('gmp')) die('skip gmp extension not loaded'); ?>
5--FILE--
6<?php
7
8var_dump(gmp_perfect_power(0));
9var_dump(gmp_perfect_power(1));
10var_dump(gmp_perfect_power(2));
11var_dump(gmp_perfect_power(4));
12var_dump(gmp_perfect_power(6));
13var_dump(gmp_perfect_power(8));
14echo "\n";
15
16var_dump(gmp_perfect_power(-1));
17var_dump(gmp_perfect_power(-2));
18var_dump(gmp_perfect_power(-4));
19var_dump(gmp_perfect_power(-6));
20var_dump(gmp_perfect_power(-8));
21echo "\n";
22
23$n = gmp_init("7442665456261594668083173595997");
24var_dump(gmp_perfect_power($n));
25var_dump(gmp_perfect_power($n+1));
26
27?>
28--EXPECT--
29bool(true)
30bool(true)
31bool(false)
32bool(true)
33bool(false)
34bool(true)
35
36bool(true)
37bool(false)
38bool(false)
39bool(false)
40bool(true)
41
42bool(true)
43bool(false)
44