procedure adp: additive digital persistence procedure adr: additive digital root procedure amean: arithmetic mean procedure ceil: ceiling procedure commas: insert commas in number procedure decimal: decimal expansion of rational procedure decipos: position decimal point procedure digred: sum digits of integer repeated to one digit procedure digroot: digital root procedure digprod: product of digits procedure digsum: sum of digits procedure distseq: generate low to high nonsequentially procedure div: real division procedure fix: format real number procedure floor: floor procedure frn: format real number procedure gcd: greatest common divisor procedure gcdl: greatest common divisor of list procedure gmean: geometric mean procedure hmean: harmonic mean procedure large: detect large integers procedure lcm: least common multiple procedure lcml: least common multiple of list procedure mantissa: mantissa (fractional part) procedure max: maximum value procedure mdp: multiplicative digital persistence procedure mdr: multiplicative digital root procedure min: minimum value procedure mod1: modulus for 1-based integers procedure npalins: palindromic numbers procedure qmean: quadratic mean procedure residue: residue for j-based integers procedure roman: convert integer to Roman numeral procedure round: round real procedure sigma: synonym for digroot() procedure sign: sign procedure spell: spell integer in American English procedure sum: sum of numbers procedure trunc: truncate real procedure unroman: convert Roman numeral to integer
link numbers
March 17, 2014; Ralph E. Griswold
Contributors: Robert J. Alexander, Richard Goerwitz
Tim Korb, Gregg M. Townsend, David Gamey, Steve Wampler
This file is in the public domain.
These procedures deal with numbers in various ways: adp(i) additive digital persistence of i adr(i) additive digital root of i (same as digred()) amean ! L returns arithmetic mean of numbers in L. ceil(r) returns nearest integer to r away from 0. commas(s) inserts commas in s to separate digits into groups of three. decimal(i, j) decimal expansion of i / j; terminates when expansion terminates or the end of a recurring period is reached. The format of the returned value is <integer>.<seq>, where <seq> is a string a decimal digits if the expansion is finite but <pre>[<recurr>] if it is not, where <pre> is a string of decimal digits (possibly empty) before the recurring part. decipos(r, i, j) positions decimal point at i in real number r in field of width j. digprod(i) product of digits of i digred(i) reduction of number by adding digits until one digit is reached. digroot(i) same as digred(). digsum(i) sum of digits in i. distseq(i, j) generates i to j in distributed order. div(i, j) produces the result of real division of i by j. fix(i, j, w, d) formats i / j as a real (floating-point) number in a field of width w with d digits to the right of the decimal point, if possible. j defaults to 1, w to 8, and d to 3. If w is less than 3 it is set to 3. If d is less than 1, it is set to 1. The function fails if j is 0 or if the number cannot be formatted. floor(r) nearest integer to r toward 0. frn(r, w, d) format real number r into a string with d digits after the decimal point; a result narrower than w characters is padded on the left with spaces. Fixed format is always used; there is no exponential notation. Defaults: w 0, d 0 gcd(i, j) returns greatest common divisor of abs(i) and abs(j). gcdl ! L returns the greatest common divisor of the integers in list L. gmean ! L returns geometric mean of numbers in L. hmean ! L returns harmonic mean of numbers in L. large(i) succeeds if i is a large integer but fails otherwise. lcm(i, j) returns the least common multiple of i and j. lcml ! L returns the least common multiple of the integers in the list L. mantissa(r) mantissa (fractional part) of r. max ! L produces maximum of numbers in L. mdp(i) multiplicative digital persistence of i mdr(i) multiplicative digital root of i min ! L produces minimum of numbers in L. mod1(i, m) residue for 1-based indexing. npalins(n) generates palindromic n-digit numbers. qmean ! L returns quadratic mean (RMS) of numbers in L. residue(i, m, j) residue for j-based indexing. roman(i) converts i to Roman numerals. round(r) returns nearest integer to r. sigma(i) synonym for digroot(i) sign(r) returns sign of r. spell(i) spells out i in American English. sum ! L sum of numbers in list L trunc(r) returns nearest integer to r toward 0 unroman(s) converts Roman numerals to integers.