You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Collection of mathematical and math related functions
FACTORS - DIVISORS (array)
* Get all divisors of $x
* if $all==true return the other half
* Output #1 (default): factors(10) => array(1=>10,2=>5)
* Output #2 : factors(10,true) => array(1=>10,2=>5,5=>2,10=>1)
function factors($x,$all=false,$onlyCount=false)
sum all proper divisors (1 included, N excluded)
function sumFactors($x)
get the first factor (v2)
* return: array(0,1)
function firstFactor($x)
LCD: LOWEST COMMON DIVISOR
* Input: A < B !!!
function lcd($a,$b)
LCM: LOWEST COMMON MULTIPLE
* Input: array() !!!
function lcm($a)
PRIME FACTORS
* Needs a prime slieve !!! with primes as keys !!!
* Will return all primes that factor in the number (and their powers) unless $howMany is set over 1
* Will return false is $howMany is set and prime factors differ from $howMany (except value 1)
* - using this with a prime number will just waste time
* Default: Return lowest base at highest power
* Backwards: Return highest base -at least squared-
* Fallback: Return the number itself at power 1
* eg. unpow(1024) => array(2,10)
* eg. unpow(1024,true) => array(32,2)
* Return next lexicographic permutation of the array
function permute($array)
INCREASE UNIQUE
* Make unique sets for given $base
function inc_uniq($a,$base,$autoExpand=false)
STRIP ZEROES (string)
* Strip leading zeroes
* Output : strip0('00009') => 9
function strip0($n)
REPEATING SUB STRING
* Get the first (shortest) repeating substring
* Useful with fractions::repeating decimals
function repeatingSubString($s)
SUB STRINGS (array)
* Get all posible substrings from (string) $s
* Output : subStrings('1234') => array('1234','123','234','12','23','34','1','2','3','4')
* Output : subStrings('abc') => array('abc','ab','bc','a','b','c')
function subStrings($s)
WORD SCORE
* score a word (eg. 'Bay'=2+1+25=28)
function wordScore($word)
ADD DIGITS
* Add up all digits in a number
function addDigits($stringNumber)
SPELL NUMBER
* Up to 999 in English (translate for more langs)
function spellNumber($number,$separator=' ',$useAND=true)
DIVISOR OF 1 (bool)
* Dummy
function
* Output : true !!!
function divisor1($n)
function divisor2($n)
DIVISOR OF 3 (bool)
* Evaluate if very big integer is divisible
* Fallback on engine math if it can handle it //(Slower)???
* Input: (string) !!!
* Output : true/false
function divisor3($n)
DIVISOR OF 4 (bool)
* Evaluate if very big integer is divisible
* Fallback on engine math if it can handle it
* Input: (string) !!!
* Output : true/false
function divisor4($n)
DIVISOR OF 5 (bool)
* Evaluate if very big integer is divisible
* Input: (string) !!!
* Output : true/false
function divisor5($n)
DIVISOR OF 6 (bool)
* Evaluate if very big integer is divisible
* Input: (string) !!!
* Output : true/false
function divisor6($n)
DIVISOR OF 7 (bool)
* Evaluate if very big integer is divisible
* Input: (string) !!!
* Output : true/false