diff --git a/Maths/Abs.js b/Maths/Abs.js index a418ee35f3..401c9e09ff 100644 --- a/Maths/Abs.js +++ b/Maths/Abs.js @@ -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 } diff --git a/Maths/Area.js b/Maths/Area.js index a047b92223..8b4c0527c2 100644 --- a/Maths/Area.js +++ b/Maths/Area.js @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ diff --git a/Maths/AverageMean.js b/Maths/AverageMean.js index 75f7b1b58e..fe5f67d3d4 100644 --- a/Maths/AverageMean.js +++ b/Maths/AverageMean.js @@ -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 diff --git a/Maths/BinaryConvert.js b/Maths/BinaryConvert.js index b1b6ce7fcc..0ebd8fee2f 100644 --- a/Maths/BinaryConvert.js +++ b/Maths/BinaryConvert.js @@ -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 diff --git a/Maths/CheckKishnamurthyNumber.js b/Maths/CheckKishnamurthyNumber.js index 7a0cc9a0cc..2cdf86d688 100644 --- a/Maths/CheckKishnamurthyNumber.js +++ b/Maths/CheckKishnamurthyNumber.js @@ -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 */ diff --git a/Maths/CircularArc.js b/Maths/CircularArc.js index b1d819323c..5ef43d110a 100644 --- a/Maths/CircularArc.js +++ b/Maths/CircularArc.js @@ -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 */ @@ -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 */ diff --git a/Maths/DecimalExpansion.js b/Maths/DecimalExpansion.js index 4cd8303d6b..b752091900 100644 --- a/Maths/DecimalExpansion.js +++ b/Maths/DecimalExpansion.js @@ -2,7 +2,7 @@ * @author Eric Lavault * * 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. diff --git a/Maths/ExponentialFunction.js b/Maths/ExponentialFunction.js index 11da977575..c8cdc88228 100644 --- a/Maths/ExponentialFunction.js +++ b/Maths/ExponentialFunction.js @@ -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) { diff --git a/Maths/FermatPrimalityTest.js b/Maths/FermatPrimalityTest.js index 331c168eea..3315b322de 100644 --- a/Maths/FermatPrimalityTest.js +++ b/Maths/FermatPrimalityTest.js @@ -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 @@ -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 diff --git a/Maths/FigurateNumber.js b/Maths/FigurateNumber.js index 058972dee6..a5d3813e93 100644 --- a/Maths/FigurateNumber.js +++ b/Maths/FigurateNumber.js @@ -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) */ diff --git a/Maths/FindMaxRecursion.js b/Maths/FindMaxRecursion.js index 9ef2982fed..4e89522eae 100644 --- a/Maths/FindMaxRecursion.js +++ b/Maths/FindMaxRecursion.js @@ -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) * diff --git a/Maths/FindMin.js b/Maths/FindMin.js index 9eee78dc7e..cec0a0720a 100644 --- a/Maths/FindMin.js +++ b/Maths/FindMin.js @@ -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) => { diff --git a/Maths/GetEuclidGCD.js b/Maths/GetEuclidGCD.js index 5499057d78..3dd67138ba 100644 --- a/Maths/GetEuclidGCD.js +++ b/Maths/GetEuclidGCD.js @@ -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) { diff --git a/Maths/HexagonalNumber.js b/Maths/HexagonalNumber.js index 31fac7ea75..3558e21bad 100644 --- a/Maths/HexagonalNumber.js +++ b/Maths/HexagonalNumber.js @@ -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) => { diff --git a/Maths/IsEven.js b/Maths/IsEven.js index d12a4dd335..3cfce820b9 100644 --- a/Maths/IsEven.js +++ b/Maths/IsEven.js @@ -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} diff --git a/Maths/IsOdd.js b/Maths/IsOdd.js index f68e2a6077..b59d655806 100644 --- a/Maths/IsOdd.js +++ b/Maths/IsOdd.js @@ -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} diff --git a/Maths/LiouvilleFunction.js b/Maths/LiouvilleFunction.js index f13916d55d..ed7387d181 100644 --- a/Maths/LiouvilleFunction.js +++ b/Maths/LiouvilleFunction.js @@ -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' diff --git a/Maths/MatrixMultiplication.js b/Maths/MatrixMultiplication.js index b6626d0190..57382ecc76 100644 --- a/Maths/MatrixMultiplication.js +++ b/Maths/MatrixMultiplication.js @@ -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++) { diff --git a/Maths/MeanAbsoluteDeviation.js b/Maths/MeanAbsoluteDeviation.js index 55585592b6..0dca360bf0 100644 --- a/Maths/MeanAbsoluteDeviation.js +++ b/Maths/MeanAbsoluteDeviation.js @@ -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) { diff --git a/Maths/MobiusFunction.js b/Maths/MobiusFunction.js index bd268b8bbd..d124ca13dd 100644 --- a/Maths/MobiusFunction.js +++ b/Maths/MobiusFunction.js @@ -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' diff --git a/Maths/PermutationAndCombination.js b/Maths/PermutationAndCombination.js index ba99888ce0..3d27679fdf 100644 --- a/Maths/PermutationAndCombination.js +++ b/Maths/PermutationAndCombination.js @@ -5,10 +5,11 @@ /** * @brief Calculates the factorial of the given number. - * @param num: integer * @details Factorial of n = n * (n - 1) * (n - 2) * ... * 1 - * @returns integer: Factorial of the number. - NaN: if negative number is provided. + * + * @returns {number}: Factorial of the number. + NaN: if negative number is provided. + * @param n */ const factorial = (n) => { if (n >= 0) { @@ -24,11 +25,10 @@ const factorial = (n) => { /** * @brief Calculates the number of Permutations from the given data. - * @param - * n: integer -> number of items. - * r: integer -> number of times n is taken. - * @returns integer: The number of permutations. - NaN: if negative number is provided. + * @param n {number} -> number of items. + * @param r {number} -> number of times n is taken. + * @returns {number}: The number of permutations. + NaN: if negative number is provided. */ const permutation = (n, r) => { return factorial(n) / factorial(n - r) @@ -36,11 +36,10 @@ const permutation = (n, r) => { /** * @brief Calculates the number of Combinations from the given data. - * @param - * n -> number of items. - * r -> number of times n is taken. - * @returns integer: The number of combinations. - NaN: if negative number is provided. + * @param {number} n -> number of items. + * @param {number} r -> number of times n is taken. + * @returns {number}: The number of combinations. + NaN: if negative number is provided. */ const combination = (n, r) => { return factorial(n) / (factorial(r) * factorial(n - r)) diff --git a/Maths/PiApproximationMonteCarlo.js b/Maths/PiApproximationMonteCarlo.js index 882818601d..eb01908d07 100644 --- a/Maths/PiApproximationMonteCarlo.js +++ b/Maths/PiApproximationMonteCarlo.js @@ -14,8 +14,7 @@ const piEstimation = (iterations = 100000) => { } // formula for pi = (ratio of number inside circle and total iteration) x 4 - const pi = (circleCounter / iterations) * 4 - return pi + return (circleCounter / iterations) * 4 } export { piEstimation } diff --git a/Maths/PowLogarithmic.js b/Maths/PowLogarithmic.js index ff57d14ef7..f4a0de028e 100644 --- a/Maths/PowLogarithmic.js +++ b/Maths/PowLogarithmic.js @@ -9,9 +9,9 @@ import { isEven } from './IsEven' * * @function PowLogarithmic * @description Given two integers x and n, return x^n in logarithmic complexity. - * @param {Integer} x - The input integer - * @param {Integer} n - The input integer - * @return {Integer} - Returns x^n. + * @param {Number} x - The input integer + * @param {Number} n - The input integer + * @return {Number} - Returns x^n. * @see [Pow-Logarithmic](https://www.geeksforgeeks.org/write-a-c-program-to-calculate-powxn/) */ const powLogarithmic = (x, n) => { diff --git a/Maths/ReverseNumber.js b/Maths/ReverseNumber.js index 2f29903c93..31cbdaf1ad 100644 --- a/Maths/ReverseNumber.js +++ b/Maths/ReverseNumber.js @@ -4,7 +4,7 @@ /** * ReverseNumber return the reversed value of the given number. - * @param {Number} n any digit number. + * @param {Number} number any digit number. * @returns `Number` n reverse in reverse. */ const ReverseNumber = (number) => { diff --git a/Maths/ShorsAlgorithm.js b/Maths/ShorsAlgorithm.js index 302a7ac644..bc0cc62ada 100644 --- a/Maths/ShorsAlgorithm.js +++ b/Maths/ShorsAlgorithm.js @@ -1,8 +1,8 @@ /** * @function ShorsAlgorithm * @description Classical implementation of Shor's Algorithm. - * @param {Integer} num - Find a non-trivial factor of this number. - * @returns {Integer} - A non-trivial factor of num. + * @param {Number} num - Find a non-trivial factor of this number. + * @returns {Number} - A non-trivial factor of num. * @see https://en.wikipedia.org/wiki/Shor%27s_algorithm * @see https://www.youtube.com/watch?v=lvTqbM5Dq4Q * diff --git a/Maths/SieveOfEratosthenesIntArray.js b/Maths/SieveOfEratosthenesIntArray.js index 56336ce7d8..3c0268e47d 100644 --- a/Maths/SieveOfEratosthenesIntArray.js +++ b/Maths/SieveOfEratosthenesIntArray.js @@ -1,7 +1,7 @@ /** * Function to get all prime numbers below a given number * This function returns an array of prime numbers - * @see {@link https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes} + * @external_link (Sieve_of_Eratosthenes)[https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes] */ function sieveOfEratosthenes(max) { diff --git a/Maths/TwinPrime.js b/Maths/TwinPrime.js index 0bb17e0ebe..e0754c7072 100644 --- a/Maths/TwinPrime.js +++ b/Maths/TwinPrime.js @@ -4,8 +4,8 @@ import { PrimeCheck } from './PrimeCheck' * @function twinPrime * Gets the 'twin prime' of a prime number. * - * @param {Integer} n The number to find the twin prime of. - * @returns {Integer} Either the twin, or -1 if n or n + 2 is not prime. + * @param {Number} n The number to find the twin prime of. + * @returns {Number} Either the twin, or -1 if n or n + 2 is not prime. * * @see https://en.wikipedia.org/wiki/Twin_prime *