Data Types
Number

Number

Following operations are supported on number data type.

Reverse Number

Returns the reverse of the given number.

Usage

reverseNumber(3245); // Returns 5423

Returns

Returns the reverseof the number.

Prime Number

Checks if the given number is prime or not.

Usage

isPrime(23); // Returns `true`

Returns

Returns true is the given number is prime, otherwise false.

Palindrome Number

Checks if the given number is palindrome or not.

Usage

isNumberPalindrome(23632); // Returns `true`

Returns

Returns true is the given number is palindrome, otherwise false.

Factorial

Returns the factorial (n!) of the given number.

Usage

factorial(5); // Returns 120

Returns

Returns the factorial of the given number.

Permutations

Returns the possible number of arrangements (nPk) can be formed from selecting k items from a set of n items. The order of the arrangement matters here.

k value must be smaller or equal to the n.

Usage

permutations(5, 4); // i.e. 5P4 Checks the number of ways 4 items can be arranged out of 5, will return result as 120.

Arguments

  • n: Number of items in a set.
  • k: Number of items arranged from n.

Returns

Returns the number of ways to arrange 4 items out of 5.

Combinations

Returns the possible number of ways (nCk) of selecting k items from a set of n items. The order of the arrangement doesn't matter here.

k value must be smaller or equal to the n.

Usage

combinations(5, 4); // i.e. 5C4 Checks the number of ways 4 items can be selected out of 5, will return result as 5.

Arguments

  • n: Number of items in a set.
  • k: Number of items selected from n.

Returns

Returns the number of ways to select 4 items out of 5.