npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

methodus

v1.0.72

Published

A Math Library inspired by Project Euler

Downloads

27

Readme

Methodus.js

Version 1.0.72 | NPM | Github

Named after Euler's work which includes 100 problems that Euler considers to illustrate his methods, and was, in all likelihood, part of the inspiration for Project Euler. Thus, the library is an arbitrary list of mathematical algorithms and helper functions that are useful for, among other things, solving the Project Euler problems.

I'm I wrestled a bear once on Project Euler and I'm building this library as I work through the problems.

enter image description here

Usage

Create a new instance with const m = new Methodus. The constructor does not accept any arguments.

Methods

| Method | Description | |--------|-------------| | m.allFactors(123) | Will return an array of all factors of 123 both prime and composite. | | m.count(myArray, 4) | Will return an integer representing the number of times 4 occurs in myArray. | | m.everySubsequence(seq, 4, funct) | Will execute funct for every 4 item subsequence in the array seq, passing the starting index of the current sequence and 4 char subsequence as an array to funct. | | m.everyDescDiagSubsequence(grid, 4, funct) | Will execute funct for every descending diagonal sequence of len items in the 2D array grid. The x position, y position and subsequence array are passed to funct. | | m.everyLinearSubsequence(grid, 4, funct) | Will execute funct for every vertical, horizontal and diagonal sequence of len items in the 2D array grid. The x position, y position, direction and subsequence array are passed to funct. | | m.everyAscDiagSubsequence(grid, 4, funct) | Will execute funct for every ascending diagonal sequence of len items in the 2D array grid. The x position, y position and subsequence array are passed to funct. | | m.everyVerticalSubsequence(grid, len, funct) | Will execute funct for every vertical sequence of len items in the 2D array grid. The x position, y position and subsequence array are passed to funct. | | m.firstNPrimes(5) | Will return an array containing the first 5 prime numbers. | | m.generatePrimes(funt) | Will call funct once for every prime number generated until funct returns false; | | m.nthPrime(8) | Will return the 8th Prime number. | | m.primeFactors(1233) | Will return n array containing the prime factorization of 1233. | | m.range(3,78) | Will return an array of numbers ranging from 3 to 78 | | m.smallestCommonMultiple(123, 32, 12, 32) | Will return the smallest common multiple of all the arguments passed to it. You can pass as many arguments as you need. | | m.greatestCommonDivisor(1.0.72) | Will return the greatest common divisor of the two numbers passed to it. | | m.pythagoreanTripletFromCircumference(1000) | Will generate a Pythagorean triplet for a triangle whose circumference is 1000. | | m.generateTriangleNumbers(funct) | Will call funct once for every triangle number until funct returns false. The function is provided the index of the triangle number and it's value. | | m.addInts(arr) | Will add the large integers in the array arr and return the sum. | | m.collatzSequence(int) | Will create and return a Collatz sequence starting at the int position. | | m.binomialCoefficient(m,n) | Will calculate m choose n. | | m.multiplyInts(a, b) | Will return the product of a and b. | | m.powInts(4,5) | Will return the value of 4 to the 5th power. | | m.numToEnglish(n) | Will convert n (any integer less than 65 digits) to English words. | | m.maxTrianglePathSum(triangle) | Given a 2D array of integers (triangle) where each index is exactly one item longer than the last - It will determine the maximum possible sum of the possible paths from the top to the bottom. | | m.factorial(n) | Will return the factorial of n. | | m.isAbundant(n) | Will return true if n is an abundant number, else false. | | m.permute(arr, limit) | Will all permutations of arr, optionally truncating at the given limit, if provided. | | m.fibonacci(funct) | Will continue to call funct, passing it the index of the fibonacci sequence as well as the value at that index (starting at one) until the function returns false. | | m.divideInts(a, b, perens, limit) | Will return the result of a divided by b. If perens is true it will put repeating digits in parentheses. Result is truncated after the first occurrence of repeating digits, or at the number of digits defined by limit. |