Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/rimbu/typical/mod.ts>Num.Pow

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias Num.Pow
import { type Num } from "https://deno.land/x/rimbu@1.0.2/typical/mod.ts";
const { Pow } = Num;

Returns the power of the first natural number to the second given natural number.

Examples

Example 1

Pow<2, 0> => 1
Pow<2, 3> => 8
Pow<3, 4> => 81

Type Parameters

N1 extends number
N2 extends number
definition: N1 extends 0 ? 0 : N2 extends 0 ? 1 : N2 extends 1 ? N1 : N2 extends 2 ? Mult<N1, N1> : IsEven<N2> extends true ? Pow<Mult<N1, N1>, Div<N2, 2>> : Mult<N1, Pow<N1, Decr<N2>>>