Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maths/Abs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const abs = (num) => {
throw new TypeError('Argument is NaN - Not a Number')
}

return validNumber < 0 ? -validNumber : validNumber // if number is less then zero mean negative then it converted to positive. i.e -> n = -2 = -(-2) = 2
return validNumber < 0 ? -validNumber : validNumber // if number is less than zero mean negative then it converted to positive. i.e -> n = -2 = -(-2) = 2
}

export { abs }
56 changes: 28 additions & 28 deletions Maths/Area.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/**
* @function surfaceAreaCube
* @description Calculate the Surface Area of a Cube.
* @param {Integer} side - Integer
* @return {Integer} - 6 * side ** 2
* @param {Number} side - Number
* @return {Number} - 6 * side ** 2
* @see [surfaceAreaCube](https://en.wikipedia.org/wiki/Area#Surface_area)
* @example surfaceAreaCube(1) = 6
*/
Expand All @@ -18,8 +18,8 @@ const surfaceAreaCube = (side) => {
/**
* @function surfaceAreaSphere
* @description Calculate the Surface Area of a Sphere.
* @param {Integer} radius - Integer
* @return {Integer} - 4 * pi * r^2
* @param {Number} radius - Number
* @return {Number} - 4 * pi * r^2
* @see [surfaceAreaSphere](https://en.wikipedia.org/wiki/Sphere)
* @example surfaceAreaSphere(5) = 314.1592653589793
*/
Expand All @@ -31,9 +31,9 @@ const surfaceAreaSphere = (radius) => {
/**
* @function areaRectangle
* @description Calculate the area of a rectangle.
* @param {Integer} length - Integer
* @param {Integer} width - Integer
* @return {Integer} - width * length
* @param {Number} length - Number
* @param {Number} width - Number
* @return {Number} - width * length
* @see [areaRectangle](https://en.wikipedia.org/wiki/Area#Quadrilateral_area)
* @example areaRectangle(4) = 16
*/
Expand All @@ -46,8 +46,8 @@ const areaRectangle = (length, width) => {
/**
* @function areaSquare
* @description Calculate the area of a square.
* @param {Integer} side - Integer
* @return {Integer} - side ** 2.
* @param {Number} side - Number
* @return {Number} - side ** 2.
* @see [areaSquare](https://en.wikipedia.org/wiki/Square)
* @example areaSquare(4) = 16
*/
Expand All @@ -59,9 +59,9 @@ const areaSquare = (side) => {
/**
* @function areaTriangle
* @description Calculate the area of a triangle.
* @param {Integer} base - Integer
* @param {Integer} height - Integer
* @return {Integer} - base * height / 2.
* @param {Number} base - Number
* @param {Number} height - Number
* @return {Number} - base * height / 2.
* @see [areaTriangle](https://en.wikipedia.org/wiki/Area#Triangle_area)
* @example areaTriangle(1.66, 3.44) = 2.8552
*/
Expand All @@ -74,10 +74,10 @@ const areaTriangle = (base, height) => {
/**
* @function areaTriangleWithAllThreeSides
* @description Calculate the area of a triangle with the all three sides given.
* @param {Integer} side1 - Integer
* @param {Integer} side2 - Integer
* @param {Integer} side3 - Integer
* @return {Integer} - area of triangle.
* @param {Number} side1 - Number
* @param {Number} side2 - Number
* @param {Number} side3 - Number
* @return {Number} - area of triangle.
* @see [areaTriangleWithAllThreeSides](https://en.wikipedia.org/wiki/Heron%27s_formula)
* @example areaTriangleWithAllThreeSides(5, 6, 7) = 14.7
*/
Expand Down Expand Up @@ -105,9 +105,9 @@ const areaTriangleWithAllThreeSides = (side1, side2, side3) => {
/**
* @function areaParallelogram
* @description Calculate the area of a parallelogram.
* @param {Integer} base - Integer
* @param {Integer} height - Integer
* @return {Integer} - base * height
* @param {Number} base - Number
* @param {Number} height - Number
* @return {Number} - base * height
* @see [areaParallelogram](https://en.wikipedia.org/wiki/Area#Dissection,_parallelograms,_and_triangles)
* @example areaParallelogram(5, 6) = 24
*/
Expand All @@ -120,10 +120,10 @@ const areaParallelogram = (base, height) => {
/**
* @function areaTrapezium
* @description Calculate the area of a trapezium.
* @param {Integer} base1 - Integer
* @param {Integer} base2 - Integer
* @param {Integer} height - Integer
* @return {Integer} - (1 / 2) * (base1 + base2) * height
* @param {Number} base1 - Number
* @param {Number} base2 - Number
* @param {Number} height - Number
* @return {Number} - (1 / 2) * (base1 + base2) * height
* @see [areaTrapezium](https://en.wikipedia.org/wiki/Trapezoid)
* @example areaTrapezium(5, 12, 10) = 85
*/
Expand All @@ -137,8 +137,8 @@ const areaTrapezium = (base1, base2, height) => {
/**
* @function areaCircle
* @description Calculate the area of a circle.
* @param {Integer} radius - Integer
* @return {Integer} - Math.PI * radius ** 2
* @param {Number} radius - Number
* @return {Number} - Math.PI * radius ** 2
* @see [areaCircle](https://en.wikipedia.org/wiki/Area_of_a_circle)
* @example areaCircle(5, 12, 10) = 85
*/
Expand All @@ -150,9 +150,9 @@ const areaCircle = (radius) => {
/**
* @function areaRhombus
* @description Calculate the area of a rhombus.
* @param {Integer} diagonal1 - Integer
* @param {Integer} diagonal2 - Integer
* @return {Integer} - (1 / 2) * diagonal1 * diagonal2
* @param {Number} diagonal1 - Number
* @param {Number} diagonal2 - Number
* @return {Number} - (1 / 2) * diagonal1 * diagonal2
* @see [areaRhombus](https://en.wikipedia.org/wiki/Rhombus)
* @example areaRhombus(12, 10) = 60
*/
Expand Down
4 changes: 2 additions & 2 deletions Maths/AverageMean.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @function mean
* @description This script will find the mean value of a array of numbers.
* @param {Integer[]} nums - Array of integer
* @return {Integer} - mean of nums.
* @param {Number[]} nums - Array of integer
* @return {Number} - mean of nums.
* @see [Mean](https://en.wikipedia.org/wiki/Mean)
* @example mean([1, 2, 4, 5]) = 3
* @example mean([10, 40, 100, 20]) = 42.5
Expand Down
4 changes: 2 additions & 2 deletions Maths/BinaryConvert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @function BinaryConvert
* @description Convert the decimal to binary.
* @param {Integer} num - The input integer
* @return {Integer} - Binary of num.
* @param {Number} num - The input integer
* @return {Number} - Binary of num.
* @see [BinaryConvert](https://www.programiz.com/javascript/examples/decimal-binary)
* @example BinaryConvert(12) = 1100
* @example BinaryConvert(12 + 2) = 1110
Expand Down
2 changes: 1 addition & 1 deletion Maths/CheckKishnamurthyNumber.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Problem statement and Explanation : https://www.geeksforgeeks.org/check-if-a-number-is-a-krishnamurthy-number-or-not-2/

krishnamurthy number is a number the sum of the all factorial of the all dights is equal to the number itself.
krishnamurthy number is a number the sum of the all factorial of the all digits is equal to the number itself.
145 => 1! + 4! + 5! = 1 + 24 + 120 = 145
*/

Expand Down
12 changes: 6 additions & 6 deletions Maths/CircularArc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { degreeToRadian } from './DegreeToRadian.js'
/**
* @function circularArcLength
* @description calculate the length of a circular arc
* @param {Integer} radius
* @param {Integer} degrees
* @returns {Integer} radius * angle_in_radians
* @param {Number} radius
* @param {Number} degrees
* @returns {Number} radius * angle_in_radians
* @see https://en.wikipedia.org/wiki/Circular_arc
* @example circularArcLength(3, 45) = 2.356194490192345
*/
Expand All @@ -15,9 +15,9 @@ function circularArcLength(radius, degrees) {
/**
* @function circularArcArea
* @description calculate the area of the sector formed by an arc
* @param {Integer} radius
* @param {Integer} degrees
* @returns {Integer} 0.5 * r * r * angle_in_radians
* @param {Number} radius
* @param {Number} degrees
* @returns {Number} 0.5 * r * r * angle_in_radians
* @see https://en.wikipedia.org/wiki/Circular_arc
* @example circularArcArea(3,45) = 3.5342917352885173
*/
Expand Down
2 changes: 1 addition & 1 deletion Maths/DecimalExpansion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author Eric Lavault <https://github.com/lvlte>
*
* Represents the decimal (or binary, octal, any base from 2 to 10) expansion
* of a/b using euclidean division.
* of a/b using Euclidean division.
*
* Because this function is recursive, it may throw an error when reaching the
* maximum call stack size.
Expand Down
7 changes: 4 additions & 3 deletions Maths/ExponentialFunction.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* @function exponentialFunction
* @description Calculates the n+1 th order Taylor series approximation of exponential function e^x given n
* @param {Integer} power
* @param {Integer} order - 1
* @returns exponentialFunction(2,20) = 7.3890560989301735
* @param {Number} power
* @param {Number} n - 1
* @returns {Number}
* // exponentialFunction(2,20) = 7.3890560989301735
* @url https://en.wikipedia.org/wiki/Exponential_function
*/
function exponentialFunction(power, n) {
Expand Down
4 changes: 2 additions & 2 deletions Maths/FermatPrimalityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* a^(p - 1) % p = 1
*
* However, there are certain numbers (so called Fermat Liars) that screw things up;
* However, there are certain numbers (so-called Fermat Liars) that screw things up;
* if a is one of these liars the equation will hold even though p is composite.
*
* But not everything is lost! It's been proven that at least half of all integers
Expand All @@ -24,7 +24,7 @@
* infallible program is around 1.4 * 10^-15. An order of magnitude below!
*
* But because nothing is perfect, there's a major flaw to this algorithm, and
* the cause are the so called Carmichael Numbers. These are composite numbers n
* the cause are the so-called Carmichael Numbers. These are composite numbers n
* that hold the equality from Fermat's Little Theorem for every a < n (excluding
* is factors). In other words, if we are trying to determine if a Carmichael Number
* is prime or not, the chances of getting a wrong answer are pretty high! Because
Expand Down
2 changes: 1 addition & 1 deletion Maths/FigurateNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Example:
Triangular => (0, 1, 3, 6, 10, 15, 21, 28, 36, 45)
Tetrahedral => (1, 4, 10, 20, 35, 56, 84, 120, 165,)
Tetrahedral => (1, 4, 10, 20, 35, 56, 84, 120, 165)
Pentatope => (1, 5, 15, 35, 70, 126, 210, 330, 495)
*/

Expand Down
8 changes: 4 additions & 4 deletions Maths/FindMaxRecursion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* @function findMaxRecursion
* @description This algorithm will find the maximum value of a array of numbers.
*
* @param {Integer[]} arr Array of numbers
* @param {Integer} left Index of the first element
* @param {Integer} right Index of the last element
* @param {Number[]} arr Array of numbers
* @param {Number} left Index of the first element
* @param {Number} right Index of the last element
*
* @return {Integer} Maximum value of the array
* @return {Number} Maximum value of the array
*
* @see [Maximum value](https://en.wikipedia.org/wiki/Maximum_value)
*
Expand Down
6 changes: 3 additions & 3 deletions Maths/FindMin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @function FindMin
* @description Function to find the minimum number given in an array of integers.
* @param {Integer[]} nums - Array of Integers
* @return {Integer} - The minimum number of the array.
* @description Function to find the minimum number given in an array of Numbers.
* @param {Number[]} nums - Array of Numbers
* @return {Number} - The minimum number of the array.
*/

const findMin = (...nums) => {
Expand Down
4 changes: 2 additions & 2 deletions Maths/GetEuclidGCD.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* GetEuclidGCD Euclidean algorithm to determine the GCD of two numbers
* @param {Number} a integer (may be negative)
* @param {Number} b integer (may be negative)
* @param {Number} a integer (maybe negative)
* @param {Number} b integer (maybe negative)
* @returns {Number} Greatest Common Divisor gcd(a, b)
*/
export function GetEuclidGCD(a, b) {
Expand Down
4 changes: 2 additions & 2 deletions Maths/HexagonalNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
* @function hexagonalNumber
* @description -> returns nth hexagonal number
* @param {Integer} number
* @returns {Integer} nth hexagonal number
* @param {Number} number
* @returns {Number} nth hexagonal number
*/

export const hexagonalNumber = (number) => {
Expand Down
4 changes: 2 additions & 2 deletions Maths/IsEven.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* @function isEven
* @description - Checking if number is even using divisibility by 2
*
* If number is divisible by 2 i.e remainder = 0, then it is even
* If number is divisible by 2 i.e. remainder = 0, then it is even
* therefore, the function will return true
*
* If number is not divisible by 2 i.e remainder != 0, then it is not even i.e odd
* If number is not divisible by 2 i.e. remainder != 0, then it is not even i.e odd
* therefore, the function will return false
* @param {number} number
* @return {boolean}
Expand Down
4 changes: 2 additions & 2 deletions Maths/IsOdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
/**
* @function isOdd
* @description -> Checking if number is odd using not divisibility by 2
* If number is not divisible by 2 i.e remainder = 1, then it is odd
* If number is not divisible by 2 i.e. remainder = 1, then it is odd
* therefore, the function will return true
*
* If number is divisible by 2 i.e remainder != 1, then it is even
* If number is divisible by 2 i.e. remainder != 1, then it is even
* therefore, the function will return false
* @param {number} number
* @returns {boolean}
Expand Down
4 changes: 2 additions & 2 deletions Maths/LiouvilleFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @description -> This method returns λ(n) of given number n
* returns 1 when number has even number of prime factors
* returns -1 when number has odd number of prime factors
* @param {Integer} number
* @returns {Integer} 1|-1
* @param {Number} number
* @returns {Number} 1|-1
*/

import { PrimeFactors } from './PrimeFactors.js'
Expand Down
2 changes: 1 addition & 1 deletion Maths/MatrixMultiplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This algorithm has multiple functions that ultimately check if the inputs are actually matrices and if two Matrices (that can be different sizes) can be multiplied together.
// matrices that are of the same size [2x2]x[2x2], and the second is the multiplication of two matrices that are not the same size [2x3]x[3x2].

// MatrixCheck tests to see if all of the rows of the matrix inputted have similar size columns
// MatrixCheck tests to see if all the rows of the matrix inputted have similar size columns
const matrixCheck = (matrix) => {
let columnNumb
for (let index = 0; index < matrix.length; index++) {
Expand Down
5 changes: 3 additions & 2 deletions Maths/MeanAbsoluteDeviation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { mean } from './AverageMean.js'
/**
*@function meanAbsoluteDeviation
*@description Calculates the mean absolute deviation of list of numbers
* @param {Integer} data
* @returns meanAbsoluteDeviation([2,34,5,0,-2]) = 10.480
* @param {Number} data
* @returns { Number }
* // meanAbsoluteDeviation([2,34,5,0,-2]) = 10.480
* @url https://en.wikipedia.org/wiki/Average_absolute_deviation
*/
function meanAbsoluteDeviation(data) {
Expand Down
4 changes: 2 additions & 2 deletions Maths/MobiusFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* or number has even number of prime factors
* returns 0 when number has repeated prime factor
* returns -1 when number has odd number of prime factors
* @param {Integer} number
* @returns {Integer}
* @param {Number} number
* @returns {Number}
*/

import { PrimeFactors } from './PrimeFactors.js'
Expand Down
Loading