MathPHP\Sequence\Basic::powersOfTen PHP Метод

powersOfTen() публичный статический Метод

Example: n = 5 Sequence: 10⁰, 10¹, 10², 10³, 10⁴ Sequence: 1, 10, 100, 1000, 10000 Array index: 0, 1, 2, 3, 4
public static powersOfTen ( integer $n ) : array
$n integer How many numbers in the sequence
Результат array Indexed from 0 (indexes are the power 10 is raised to)
    public static function powersOfTen(int $n) : array
    {
        $powers_of_10 = [];
        if ($n <= 0) {
            return $powers_of_10;
        }
        for ($i = 0; $i < $n; $i++) {
            $powers_of_10[] = 10 ** $i;
        }
        return $powers_of_10;
    }