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 🙏

© 2025 – Pkg Stats / Ryan Hefner

math-theory

v1.2.3

Published

Mathematical Theory 质数,最大公约数,最小公倍数,整除

Readme

Install

npm install math-theory 

How to

var theory = require('math-theory');
theory.rd(10,100,2)  // 随机数 最后一个参数支持小数位数
theory.primeFactorization(100) //分解质因数
theory.partNum(123) //分割数字 [3,2,1]
theory.getPrimes(100,10) //获取一定范围内的质因数  后面一个参数不传是从0开始
theory.checkRepeat(object,object) //查找重复项
theory.diffMedian(3)  //获取各不相同的几位数
theory.gcd(30,75) //两个数的最大公约数
theory.ngcd([30,60,75]) //多个数的最大公约数
theory.lcm(15,25)  //最小公倍数
theory.nlcm([15,25,60])  //多个数的最小公倍数
theory.isPrime(18)  //判断一个数是否为质数
theory.toFactorPowerList([2,2,2,3,5,5,7]) //将一个数组转换成N次方的序列[[2,3],[3,1],[5,2].[7,1]]
theory.permutator([1,2,3]) //排列组合 return[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
theory.getCommonDivisor(8)  //求一个数的约数 return [1,2,4,8]
theory.float2rat(0.3333333333) //将一个小数转换为分数 return string 1/3
theory.getSimpleFraction(4,8)//化简分数 return [1,2] 
theory.str2Fraction('5/2')//将一个分数字符串转换为数组 return [5,2] 
theory.point(x1,y1,x2,y2,n) //矢量与定比分点 return {'x':x,'y':y}
theory.permutations(5)//5*4*3*2*1 排列 retrun 120 
theory.combinations(5,3)//(5*4*3*2*1)/(3*2*1) 组合 return 10 
theory.factorialProcess(5,3)//阶乘中有哪几个数相乘 return [5,4,3] 

Have fun!

Copyright/License

微学记