135 Commits

Author SHA1 Message Date
cc16cbdf84 Added JugglerSequence.js (#1075) 2022-08-03 22:32:34 +05:30
1b64ba68fa Fibonacci.js overhaul (#1049) 2022-06-27 10:09:54 +05:30
92a81a2290 merge: Add Twin Primes algorithm (#1024)
* Create TwinPrime.js

* Update TwinPrime.js

* Create TwinPrime.test.js

* Update TwinPrime.js

* Update TwinPrime.js

* Add suggestions

* Update TwinPrime.test.js

* Update TwinPrime.js

* Styling
2022-05-27 21:28:45 +05:30
0357a23282 merge: Add the Collatz Conjecture (#1022)
* Create CollatzConjecture.js

* Create CollatzConjecture.test.js

* Update CollatzConjecture.js

* Update CollatzConjecture.test.js

* Rename CollatzConjecture.js to CollatzSequence.js

* Update and rename CollatzConjecture.test.js to CollatzSequence.test.js

* Update CollatzSequence.js

* Update CollatzSequence.test.js

* Update CollatzSequence.test.js

* Fix styling errors

* Add suggestion

Co-authored-by: Rak Laptudirm <rak@laptudirm.com>

* Update CollatzSequence.js

* Update CollatzSequence.js

* Update comments to match the Collatz Sequence

* Update CollatzSequence.test.js

Co-authored-by: Rak Laptudirm <rak@laptudirm.com>
2022-05-26 08:37:53 +05:30
dc67506272 merge: Add pronic number implementation (#1023)
* feat: Add pronic number implementation

* Add test to Math

* Minor fixes

* Minor style fixes

* refactor: Store square root in a variable

* Minor refactoring

* fix: Change pronic number check logic

Reduced time complexity from O(sqrt(n)) to O(1)

* Minor style fixes

* fix: Update pronic number check boolean equation

* refactor: Change pronic number check condition

* refactor: Add tests to Math

* Minor style fixes

* refactor: Change unit test logic
2022-05-25 17:39:23 +05:30
21a851176d merge: Find max recursion (#1010)
* add yt video association algorithm

* Implement FindMaxRecursion in JS

* Delete file in other PR

* Fix requested changes

* Add requested changes

* Delete YoutubeVideoAssociation.test.js

* Deduplicate comment

* Remove trailing spaces

Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
2022-05-09 15:05:16 +05:30
5641b6faea Add Zeller's Congruence Algorithm in Math (#996) 2022-04-27 14:49:12 +02:00
c81db629b8 merge: EuclidGCD: add tests (#994)
test was not present beforehand.
2022-04-22 16:21:22 +05:30
9513bcd77a merge: WhileLoopFactorial: Optimize and add tests (#992)
* Optimised the factorial function.

There was previously an unnecessary check for if the number was 0 or 1.

* Create WhileLoopFactorial.test.js

The test was not present previously.

* result *= num

* Update WhileLoopFactorial.test.js

* testFactorial function

* Space for formatting.

* should fix the formatting issues. I was having trouble with npx standard, so I just used the online verifier at https://standardjs.com/demo.html
2022-04-21 21:58:29 +05:30
eb36e2de62 merge: Format codebase with standard.js (#989)
* Auto-update DIRECTORY.md

* fix: some redundancy according to standard javascript library

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-04-21 11:38:38 +05:30
2be0fdcb49 merge: Decimal Expansion (#787)
* Add Math function for representing the decimal expansion of a given fraction (decimal or any base from 2 to 10).

* Auto-update DIRECTORY.md

* DecimalExpansion Jest tests.

* chore: trigger update

* Auto-update DIRECTORY.md

* Auto-update DIRECTORY.md

* chore: trigger checks

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Rak Laptudirm <rak@laptudirm.com>
Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
2022-04-02 20:40:57 +05:30
ffa4846994 merge: Add FindMinIterator algorithm (#928)
* FindMinIterator

Do the `standard` thing.

Rename `FindMin` to `FindMinIterator`

Rename to `FindMinIterator`

Pull `FindMin` from `master`

* Remove these separator comments.

Co-authored-by: RuSaG0 <mirzoev-ruslan-2000@mail.ru>
2022-03-16 17:31:25 +05:30
a545f76669 merge: Add test case of SquareRoot function (#926) 2022-03-15 20:39:34 +05:30
0924f1c8c9 merge: Improved abs function (#923)
* feat: added validation, test codes

* chore: remove useless words
2022-03-15 17:41:50 +05:30
da6c22704e merge: refactor isEven function (#920)
* refactor: formated docs and functions

* refactor: format all test codes
2022-03-11 22:16:02 +05:30
98c46b4d9e merge: Improved IsOdd function (#914)
* refactor: used Boolean function for conversion

* feat: added one more function and test cases

* test: refactor test case & fixed var names

* chore: fixed test placeholder
2022-03-04 16:34:33 +05:30
ab06131656 merge: Improved Pow function (#911)
* feat: add negative power option

* docs: add js doc for powOn function

* feat: add PowFaster with faster algorithm, complexity O(logN)

* chore: rename to exponent

* chore: rename fixed

* style: formated with standard
2022-03-02 09:06:40 +05:30
0178efd8df merge: Algorithm to calculate the Arithmetic Geometric Mean (#897)
* Create ArithmeticGeometricMean.js

* Finally added the test script for AGM

* Better doc, and corrected some formatting

* Fixed syntax typos

* Added more tests and made FP comparison more "loose"

* Patched bugs

* Fixed-0 bug

* Again, tried to fix minus zero

* Finally fixed all bugs (probably)

* Fixed style (probably)

* Fixed style

* Fixed all style
2022-02-24 16:15:56 +05:30
ef832f6920 merge: add areaTriangleWithAllThreeSides method in Math/Area.js (#875) 2021-12-15 23:00:11 +05:30
3d2a48f798 merge: Improve Mean method (#874) 2021-12-15 22:58:28 +05:30
bbdb5cf38a merge: Binary Convert (#865)
* Binary Convert

* Update link

* add more test cases
2021-12-14 11:01:52 +05:30
f387ff327c chore: Remove duplicate DigitSum algorithm (#873)
* Auto-update DIRECTORY.md

* chore: remove duplicate algorithm

* Auto-update DIRECTORY.md

* chore: remove duplicate algorithm tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-12-11 13:40:11 +05:30
4d55b40c9e merge: Absolute value (#866) 2021-12-11 13:29:19 +05:30
de2708990d merge: Add FindMin (#849) 2021-11-26 22:12:30 +05:30
c1c895bebd chore: Add PowLogarithmic in Math (#836)
* Add PowLogarithmic in Math

* add description
2021-11-19 10:40:51 +05:30
2619ab673f merge: Added bisection method (#827)
* feat: Added bisection method

* Auto-update DIRECTORY.md

Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-31 22:30:46 +05:30
7c39839714 merge: Add LinearSieve.js (#828) 2021-10-31 22:28:45 +05:30
1cd3b8683a merge: Created midpoint integration numerical method (#822)
* Created midpoint integration numerical method

* Auto-update DIRECTORY.md

* Added resources link

* Fixed doxumentation

* Fixed spelling error

Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-28 18:09:40 +05:30
7722870183 merge: Created composite Simpson's integration method. Tests included. (#819)
* Created composite Simpson's integration method.Tests included

* Minor corrections

* Auto-update DIRECTORY.md

* Styled with standard.js

* chore: remove blank line

* chore: remove blank line

Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
2021-10-28 15:07:07 +05:30
502aec24cb merge: Added Aliquot Sum Implementation (#810)
* Added LucasSeries

* Added more tests and renamed function

* Changed RangeError to TypeError

* Added Aliquot Sum and tests

* Fix ALiquot tests, need to learn how to use Jest

* Added some explanation for the Aliquot sum
2021-10-26 15:00:07 +05:30
69a397cc33 merge: Added LucasSeries Implementation (#808)
* Added LucasSeries

* Added more tests and renamed function

* Changed RangeError to TypeError
2021-10-25 10:03:02 +05:30
e8d862ca94 merge: Added manhattan distance and euclidean distance for distance 2 points task (#809)
* Added Hex to Binary conversion

* Update Conversions/HexToBinary.js

Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>

* Update Conversions/HexToBinary.js

Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>

* Update Conversions/HexToBinary.js

Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>

* Update Conversions/HexToBinary.js

Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>

* Fix errors

* fix: typo

* Added Manhattan Distance Algorithm

Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
2021-10-25 09:26:53 +05:30
cd3974c457 merge: Added Sum of GP (#807) 2021-10-23 23:14:01 +05:30
d38ebe5199 chore: Merge pull request #768 from lvlte/issues/720
Changes for consolidation
2021-10-21 19:32:55 +05:30
79c7ce45c8 Fixed != to !== and ran npm run style 2021-10-21 15:57:20 +05:30
56b29cab25 Merge branch 'TheAlgorithms:master' into master 2021-10-21 15:09:26 +05:30
5ccfafecbb npm run style result 2021-10-21 15:06:33 +05:30
fe56f54f82 Added Extended Euclidean Algorithm (ExtendedEuclideanGCD.js) to Maths folder, along with relevant test 2021-10-21 14:58:12 +05:30
8352d260b8 chore: Merge pull request #794 from Badhusha-Akhthaar/master
Added new Mathematical algorithm :  Figurate Numbers
2021-10-21 14:38:25 +05:30
915ca4c7ef Added new Mathematical algorithm , Figurate Numbers
Algorithm for checking whether input number does belong to any type of figurate numbers
2021-10-17 14:12:32 +05:30
ffb138adb1 Minor fixes
- Add default number of iterations
- Correct "corner cases" to "edge cases"
- Make clear which bounds are inclusive and which are exclusive
2021-10-15 12:21:48 -03:00
c5e44d498a A few suggestions / modifications / fixes
It seems you've accidentally swapped the implementation and the test file :)

The overall comment describing the algorithm (VERY nice doc, by the way) is not "proper" JSdoc => only one leading asterisk. It's generally considered good style to start a comment block (both JSdoc and regular comments) with a single, short sentence.

Further down, there were some git hiccups, most likely caused by merge conflicts?
2021-10-14 22:32:56 +02:00
3c2fdf7582 Add Fermat Primality Test 2021-10-14 15:15:49 -03:00
3f32320c85 Comply with ESM. Convert live code example to Jest test. 2021-10-09 13:25:34 +02:00
cbe7e0c89f Comply with ESM syntax. 2021-10-09 13:18:40 +02:00
b13b12e88c chore: merge Fix/742 migrate doctest to jest (#749)
* Remove QuickSelect doctest

There are more Jest test cases already.

* Remove AverageMedian doctest

Already migrated to jest

* Migrate doctest for BinaryExponentiationRecursive.js

(also remove inline "main" test method)

* Migrate doctest for EulersTotient.js

(also remove inline "main" test method)

* Migrate doctest for PrimeFactors.js

(also remove inline "main" test method)

* Migrate doctest for BogoSort.js

Re-write prototype-polluting helper methods, too.

(also remove inline test driver code)

* Migrate doctest for BeadSort.js

(also remove inline test driver code)

* Migrate doctest for BucketSort.js

(also remove inline test driver code)

* Migrate doctest for CocktailShakerSort.js

(also remove inline test driver code)

* Migrate doctest for MergeSort.js

(also remove inline test driver code)

* Migrate doctest for QuickSort.js

(also remove inline test driver code)

* Migrate doctest for ReverseString.js

(also remove inline test driver code)

* Migrate doctest for ReverseString.js

* Migrate doctest for ValidateEmail.js

* Migrate doctest for ConwaysGameOfLife.js

(remove the animate code, too)

* Remove TernarySearch doctest

Already migrated to jest

* Migrate doctest for BubbleSort.js

(also remove inline test driver code)

* Remove doctest from CI and from dependencies

relates to #742
fixes #586

* Migrate doctest for RgbHsvConversion.js

* Add --fix option to "standard" npm script

* Migrate doctest for BreadthFirstSearch.js

(also remove inline test driver code)

* Migrate doctest for BreadthFirstShortestPath.js

(also remove inline test driver code)

* Migrate doctest for EulerMethod.js

(also remove inline test driver code)

Move manual test-code for plotting stuff in the browser in a distinct file, too. Those "*.manual-test.js" files are excluded from the UpdateDirectory.mjs script, as well.

* Migrate doctest for Mandelbrot.js

(also remove inline test driver code & moved manual drawing test into a *.manual-test.js)

* Migrate doctest for FloodFill.js

* Migrate doctest for KochSnowflake.js

(also move manual drawing test into a *.manual-test.js)

* Update npm lockfile

* Update README and COMMITTING with a few bits & bobs regarding testing & code quality
2021-10-07 12:33:38 +05:30
82d1c2a6bd Merge branch 'master' into master 2021-10-06 00:00:47 +06:00
1589263947 fixed some spellings 2021-10-05 12:49:23 +05:30
bf088c0646 add an algorithm for checking a year is a leap year or not 2021-10-04 01:20:08 +06:00
b3b4ad43a3 chore: Added Sum of Digits Implementation (#684)
* Added the main logic, need to work on Tests

* Added tests for SOD

* Fix typo and add Wikipedia link in comments

* Fix mistake in SumOfDigitsUsingStrings

I intended to initially write a different implementation but I wrote something else 🤦‍♂️

* Converted Spacing from Tabs to Spaces

* Oops, forgot about the test file

* Fixed semicolon problems...

* Oops, I missed a few semicolons

* Linting is hell TwT

Co-authored-by: SpiderMath <{ID}+{username}@users.noreply.github.com>
2021-09-13 19:41:28 +05:30