Calculate

Calculate

  • Docs
  • Help
  • Blog

›Math

Getting Started

  • Installation
  • Updating Calculate

Math

  • Sum
  • Difference
  • Product
  • Quotient
  • Remainder
  • Power
  • Square
  • Cube
  • Factorial

Statistics

  • Mean
  • Median
  • Mode
  • Range

Power

Gets the power of given numbers.

Syntax

power(a: number, b: number, ...args): number

Note: It gets the power of a number from left to right with this behavior ((a ^ b) ^ c) ^ ... and so on.

Parameters

a: number - First given number.

b: number - Second given number.

...args: number[] - The rest of the given numbers

Can be given an infinite number of parameters.

Returns

number - The resulting power.

Error

Throws an error if the length of arguments is less than 2.

Import

import { power } from '@princedev/calculate';

Examples

Basic usage with two given numbers.

const result = power(2,3);

result would be 8

Getting the power of multiple given nnumbers.

const result = power(2, 3, 4);

result would be 4096 as it is evaluated as (2 ^ 3) ^ 4

If you're using an array, you can use the spread operator like this

const result = power(...[2, 3, 4]);

result would be 4096

Last updated on 5/6/2020 by Prince Neil Cedrick Castro
← RemainderSquare →
  • Syntax
    • Parameters
    • Returns
    • Error
  • Import
  • Examples
Calculate
Docs
Getting StartedGuides
Package
NPMGitHubStar
More
HelpBlog
aws.cedi@gmail.com
Copyright © 2020 Calculate