NAME
Sidef::Types::Number::Number
DESCRIPTION
The Number
class implements support for numerical operations, supporting integers, rationals, floating-points and complex numbers at arbitrary precision.
This class also implements many useful mathematical methods, from basic arithmetical operations, to advanced number-theoretic functions, including primality testing and prime factorization methods.
SYNOPSIS
var a = Num(string)
var b = Number(string, base)
INHERITS
Inherits methods from:
* Sidef::Object::Object
METHODS
!
n!
Factorial of n
. (1*2*3*...*n
)
Aliases: fac, factorial
!!
n!!
Double-factorial of n
.
Aliases: dfac, dfactorial, double_factorial
%
n % k
Remainder of n/k
.
Aliases: mod
%%
n %% k
Returns true if n
is divisible by k
. False otherwise.
Aliases: is_div
&
a & b
Bitwise AND operation.
Aliases: and
*
a * b
Multiplication of a
and b
.
Aliases: mul
**
a**b
Exponentiation: a
to power b
.
Aliases: pow
+
a + b
Addition of a
and b
.
Aliases: add
++
n.inc
Increment n
by 1
and return the result.
Aliases: inc
-
a - b
Subtraction of a
and b
.
Aliases: sub
--
n.dec
Decrement n
by 1
and return the result.
Aliases: dec
..
a .. b
Create an inclusive-inclusive RangeNum
object, from a
to b
.
Equivalent with:
RangeNum(a, b)
Aliases: to, upto
..^
a ..^ b
Create an inclusive-exclusive RangeNum
object, from a
to b-1
.
Equivalent with:
RangeNum(a, b-1)
Aliases: xto, xupto
/
a / b
Division of a
by b
.
Aliases: ÷, div
//
a // b
Integer floor-division of a
and b
.
Equivalent with:
floor(a/b)
Aliases: idiv
:
a : b
Create a new complex number.
Equivalent with:
Complex(a, b)
Aliases: pair
<
a < b
Returns true if a
is less than b
.
Aliases: lt
<<
a << b
Left shift a
by b
bits, which is equivalent with (assuming a
and b
are integers):
floor(a * 2**b)
Aliases: lsft, shift_left
<=>
a <=> b
Comparison of a
with b
. Returns -1
if a
is less than b
, 0
if a
and b
are equal and +1
if a
is greater than b
.
Aliases: cmp
approx_cmp
approx_cmp(a, b)
approx_cmp(a, b, k)
Approximate comparison of a
and b
.
Equivalent with:
a.round(k) <=> b.round(k)
When k
is omitted, it uses the default floating-point precision to deduce k
.
==
a == b
Equality check. Returns true if a
and b
are equal.
Aliases: eq
>
a > b
Returns true if a
is greater than b
. False otherwise.
Aliases: gt
>>
a >> b
Right shift a
by b
bits, which is equivalent with (assuming a
and b
are integers):
floor(a / 2**b)
Aliases: rsft, shift_right
^
a ^ b
Bitwise XOR operation.
Aliases: xor
^..
a ^.. b
Creates a reversed exclusive-inclusive RangeNum
object, from a-1
down to b
.
Equivalent with:
RangeNum(a-1, b, -1)
Aliases: xdownto
C
Num.C
Num.catalan_G
Returns the Catalan constant: 0.915965594177...
Aliases: catalan_G
Y
Number.Y() -> Obj
Return the
Aliases: γ, euler_gamma
|
Obj | Obj -> Obj
Return the
Aliases: or
~
Obj ~ Obj -> Obj
Return the
Aliases: not
Γ
Number.Γ() -> Obj
Return the
Aliases: gamma
δ
Number.δ() -> Obj
Return the
Aliases: kronecker_delta
ζ
Number.ζ() -> Obj
Return the
Aliases: zeta
η
Number.η() -> Obj
Return the
Aliases: eta
μ
Number.μ() -> Obj
Return the
Aliases: mu, mobius, möbius, moebius
Π
Number.Π() -> Obj
Return the
Aliases: prod
π
Number.π() -> Obj
Return the
Aliases: pi
Σ
Number.Σ() -> Obj
Return the
Aliases: sum
σ
Number.σ() -> Obj
Return the
Aliases: sigma
τ
Number.τ() -> Obj
Return the
Aliases: tau
φ
Number.φ() -> Obj
Return the
Aliases: phi
Ψ
Number.Ψ() -> Obj
Return the
Aliases: digamma
Ω
Number.Ω() -> Obj
Return the
Aliases: bigomega, prime_power_sigma0
ω
Number.ω() -> Obj
Return the
Aliases: omega, prime_sigma0, prime_power_usigma0
≅
Obj ≅ Obj -> Obj
Return the
Aliases: =~=, approx_eq
≠
Obj ≠ Obj -> Obj
Return the
Aliases: !=, ne
≤
Obj ≤ Obj -> Obj
Return the
Aliases: <=, le
≥
Obj ≥ Obj -> Obj
Return the
Aliases: >=, ge
abs
n.abs
Absolute value of n
.
abundancy
Number.abundancy() -> Obj
Return the
Aliases: abundancy_index
acmp
Number.acmp() -> Obj
Return the
acos
n.acos
Inverse cosine of n
in radians.
acosh
n.acosh
Inverse hyperbolic cosine of n
.
acot
n.acot
Inverse cotangent of n
in radians.
acoth
n.acoth
Inverse hyperbolic cotangent of n
.
acsc
n.acsc
Inverse cosecant of n
in radians.
acsch
n.acsch
Inverse hyperbolic cosecant of n
.
addmod
Number.addmod() -> Obj
Return the
agm
agm(a, b)
Arithmetic-geometric mean of a
and b
.
ai
x.ai
Ai(x)
Airy function of the first kind: Ai(x)
.
Aliases: airy
all_composite
Number.all_composite() -> Obj
Return the
all_prime
Number.all_prime() -> Obj
Return the
approx_ge
approx_ge(a, b)
approx_ge(a, b, k)
True if a
is approximately greater than or equal to b
.
Equivalent with:
a.round(k) >= b.round(k)
approx_gt
approx_gt(a, b)
approx_gt(a, b, k)
True if a
is approximately greater than b
.
Equivalent with:
a.round(k) > b.round(k)
approx_le
approx_le(a, b)
approx_le(a, b, k)
True if a
is approximately less than or equal to b
.
Equivalent with:
a.round(k) <= b.round(k)
approx_lt
approx_lt(a, b)
approx_lt(a, b, k)
True if a
is approximately less than b
.
Equivalent with:
a.round(k) < b.round(k)
approx_ne
approx_ne(a, b)
approx_ne(a, b, k)
True if a
is approximately different than b
.
Equivalent with:
a.round(k) != b.round(k)
as_bin
n.as_bin
Returns a String
with the binary representation of n
.
Example:
say 42.as_bin # "101011"
as_dec
n.as_dec
n.as_dec(k)
Given a rational number n
, it returns its decimal expansion as a String
object, expanded at k
decimal places.
Example:
say (1/17 -> as_dec(10)) # 0.05882352941
say (1/17 -> as_dec(30)) # 0.0588235294117647058823529411765
Aliases: as_float
asec
n.asec
Inverse secant of n
in radians.
asech
n.asech
Inverse hyperbolic secant of n
.
as_frac
n.as_frac
n.as_frac(base)
String-representation of n
as fraction.
Example:
say 24.as_frac # 24/1
say bernoulli(10).as_frac # 5/66
say bernoulli(12).as_frac(36) # -j7/23u
If n
is an integer, it uses 1
for the denominator.
as_hex
n.as_hex
Returns a String representing the integer part of n
in hexadecimal (base 16).
Example:
say 42.as_hex # "2a"
Returns nil
when n
cannot be converted to an integer.
asin
n.asin
Inverse sine of n
in radians.
asinh
n.asinh
Inverse hyperbolic sine of n
.
as_int
n.as_int
n.as_int(base)
Returns a String representing the integer part of n
in a given base, where the base must be between 2 and 62.
When the base is omitted, it defaults to base 10.
Example:
say 255.as_int # "255"
say 255.as_int(16) # "ff"
Returns nil
when n
cannot be converted to an integer.
as_oct
n.as_oct
Returns a String representing the integer part of n
in octal (base 8).
Example:
say 42.as_oct # 52
Returns nil
when n
cannot be converted to an integer.
as_rat
n.as_rat
n.as_rat(base)
Returns a rational string-representation of n
in a given base, where the base must be between 2 and 62.
When the base is omitted, it defaults to base 10.
Example:
say as_rat(42) # "42"
say as_rat(2/4) # "1/2"
say as_rat(255, 16) # "ff"
Returns nil
when n
cannot be converted to a rational number.
atan
n.atan
Inverse tangent of n
in radians.
atan2
atan2(a, b)
Four-quadrant inverse tangent of a
and b
.
atanh
n.atanh
Inverse hyperbolic tangent of n
.
base
n.base(b)
Returns a String-representation of n
in a given base b
, which must be between 2 and 62.
Aliases: in_base
bell
n.bell
Returns the n-th Bell number.
Aliases: bell_number
bern
n.bern
bernoulli(n)
bernoulli(n, x)
Returns the n-th Bernoulli number. When an additional argument is provided, it returns the n-th Bernoulli polynomial.
Example:
say bernoulli(10).as_rat # B_10 = 5/66
say bernoulli(10, 2).as_rat # B_10(2) = 665/66
Aliases: bernfrac, bernoulli, bernoulli_number
bernoulli_polynomial
bernoulli_polynomial(n, x)
Returns the n-th Bernoulli polynomial: B_n(x)
.
bernreal
n.bernreal
Return an approximation to the n-th Bernoulli number as a floating-point number.
bessel_j
bessel_j(x, n)
First order Bessel function: J_n(x)
.
bessel_y
bessel_y(x, n)
Second order Bessel function: Y_n(x)
.
beta
beta(a, b)
The beta function (also called the Euler integral of the first kind).
Defined as:
beta(a, b) = gamma(a)*gamma(b) / gamma(a+b)
bit
n.bit(k)
n.getbit(k)
Returns 1 if bit k
of n
is set, and 0 if it is not set.
Return nil
when n
cannot be truncated to an integer or when k
is negative.
Example:
say getbit(0b1001, 0) # 1
say getbit(0b1000, 0) # 0
Aliases: getbit, testbit
bits
Number.bits() -> Obj
Return the
bit_scan0
n.bit_scan0
n.bit_scan0(k)
Scan n
, starting from bit index k
, towards more significant bits, until a 0-bit is found.
When k
is omitted, k=0
is assumed.
Returns nil
if n
cannot be truncated to an integer or if k
is negative.
bit_scan1
n.bit_scan1
n.bit_scan1(k)
Scan n
, starting from bit index k
, towards more significant bits, until a 1-bit is found.
When k
is omitted, k=0
is assumed.
Returns nil
if n
cannot be truncated to an integer or if k
is negative.
bsearch
bsearch(n, {...})
bsearch(a, b, {...})
Binary search from to 0
to n
, or from a
to b
, which can be any arbitrary large integers.
The last argument is a block which does the comparisons.
This function finds a value k
such that f(k) = 0. Returns nil
otherwise.
say bsearch(20, {|k| k*k <=> 49 }) #=> 7 (7*7 = 49)
say bsearch(3, 1000, {|k| k**k <=> 3125 }) #=> 5 (5**5 = 3125)
bsearch_ge
bsearch_ge(n, {...})
bsearch_ge(a, b, {...})
Binary search from to 0
to n
, or from a
to b
, which can be any arbitrary large integers.
The last argument is a block which does the comparisons.
This function finds a value k
such that f(k-1) < 0 and f(k) >= 0. Returns nil
otherwise.
bsearch_ge(1e6, { .exp <=> 1e+9 }) # 21 (exp( 21) >= 1e+9)
bsearch_ge(-1e6, 1e6, { .exp <=> 1e-9 }) # -20 (exp(-20) >= 1e-9)
bsearch_le
bsearch_le(n, {...})
bsearch_le(a, b, {...})
Binary search from to 0
to n
, or from a
to b
, which can be any arbitrary large integers.
The last argument is a block which does the comparisons.
This function finds a value k
such that f(k) <= 0 and f(k+1) > 0. Returns nil
otherwise.
bsearch_le(1e6, { .exp <=> 1e+9 }) # 20 (exp( 20) <= 1e+9)
bsearch_le(-1e6, 1e6, { .exp <=> 1e-9 }) # -21 (exp(-21) <= 1e-9)
bsearch_max
Number.bsearch_max() -> Obj
Return the
bsearch_min
Number.bsearch_min() -> Obj
Return the
bsearch_solve
Number.bsearch_solve() -> Obj
Return the
Aliases: bsearch_inverse
by
Number.by() -> Obj
Return the
Aliases: first
cadd
Number.cadd() -> Obj
Return the
Aliases: complex_add
catalan
n.catalan
n.catalan(k)
Returns the n-th Catalan number.
If two arguments are provided, it returns the C(n,k)
entry in Catalan's triangle.
cbrt
n.cbrt
Cube root of n
.
cdiv
Number.cdiv() -> Obj
Return the
Aliases: complex_div
ceil
n.ceil
Round n
towards positive Infinity.
Aliases: ceiling
cfrac
n.cfrac
n.cfrac(k)
Compute k
terms of the simple continued-fraction expansion of n
.
Example:
say sqrt(12).cfrac(6) # [3, 2, 6, 2, 6, 2, 6]
Can also be used to compute very good rational approximations to a given real number:
say Num.pi.cfrac(10).flip.reduce{|a,b| b + 1/a }.as_rat # 4272943/1360120
When k
is omitted, it uses the default floating-point precision to deduce k
.
Aliases: as_cfrac
chebyshev_T
chebyshevT(n, x)
Compute the Chebyshev polynomials of the first kind: T_n(x)
, where n
must be a native integer.
Defined as:
T(0, x) = 1
T(1, x) = x
T(n, x) = 2*x*T(n-1, x) - T(n-2, x)
Aliases: chebyshevt, chebyshevT
chebyshev_U
chebyshevU(n, x)
Compute the Chebyshev polynomials of the second kind: U_n(x)
, where n
must be a native integer.
Defined as:
U(0, x) = 1
U(1, x) = 2*x
U(n, x) = 2*x*U(n-1, x) - U(n-2, x)
Aliases: chebyshevu, chebyshevU
chr
n.chr
Convert the integer n
into a character.
Example:
say 97.chr # "a"
say 9786.chr # "☺"
cinv
Number.cinv() -> Obj
Return the
Aliases: complex_inv
cinvmod
Number.cinvmod() -> Obj
Return the
Aliases: complex_invmod
circular_permutations
Number.circular_permutations() -> Obj
Return the
cis
Number.cis() -> Obj
Return the
clearbit
Number.clearbit() -> Obj
Return the
cmod
Number.cmod() -> Obj
Return the
Aliases: complex_mod
cmul
Number.cmul() -> Obj
Return the
Aliases: complex_mul
combinations
Number.combinations() -> Obj
Return the
combinations_with_repetition
Number.combinations_with_repetition() -> Obj
Return the
commify
Number.commify() -> Obj
Return the
complex
Number.complex() -> Obj
Return the
complex_cmp
Number.complex_cmp() -> Obj
Return the
complex_ipow
Number.complex_ipow() -> Obj
Return the
composite
Number.composite() -> Obj
Return the
Aliases: nth_composite
composite_count
Number.composite_count() -> Obj
Return the
conj
Number.conj() -> Obj
Return the
Aliases: conjug, conjugate
consecutive_lcm
Number.consecutive_lcm() -> Obj
Return the
Aliases: consecutive_integer_lcm
convergents
Number.convergents() -> Obj
Return the
core
Number.core() -> Obj
Return the
cos
Number.cos() -> Obj
Return the
cosh
Number.cosh() -> Obj
Return the
cot
Number.cot() -> Obj
Return the
coth
Number.coth() -> Obj
Return the
cpow
Number.cpow() -> Obj
Return the
Aliases: complex_pow
cpowmod
Number.cpowmod() -> Obj
Return the
Aliases: complex_powmod
csc
Number.csc() -> Obj
Return the
csch
Number.csch() -> Obj
Return the
csub
Number.csub() -> Obj
Return the
Aliases: complex_sub
cyclotomic
Number.cyclotomic() -> Obj
Return the
Aliases: cyclotomic_polynomial
dconv
Number.dconv() -> Obj
Return the
Aliases: dirichlet_convolution
de
Number.de() -> Obj
Return the
Aliases: denominator
defs
Number.defs() -> Obj
Return the
deg2rad
Number.deg2rad() -> Obj
Return the
derangements
Number.derangements() -> Obj
Return the
Aliases: complete_permutations
derivative
Number.derivative() -> Obj
Return the
Aliases: arithmetic_derivative
digit
Number.digit() -> Obj
Return the
digits
Number.digits() -> Obj
Return the
digits2num
Number.digits2num() -> Obj
Return the
Aliases: from_digits
digits_sum
Number.digits_sum() -> Obj
Return the
Aliases: sum_digits, sumdigits
dirichlet_sum
Number.dirichlet_sum() -> Obj
Return the
Aliases: dirichlet_hyperbola
divides
Number.divides() -> Obj
Return the
divisor_map
Number.divisor_map() -> Obj
Return the
divisor_prod
Number.divisor_prod() -> Obj
Return the
Aliases: divisors_prod
divisors
Number.divisors() -> Obj
Return the
divisor_sum
Number.divisor_sum() -> Obj
Return the
Aliases: divisors_sum
divmod
Number.divmod() -> Obj
Return the
downto
Number.downto() -> Obj
Return the
dump
Number.dump() -> Obj
Return the
e
Number.e() -> Obj
Return the
each_prime
Number.each_prime() -> Obj
Return the
Aliases: primes_each
each_squarefree
Number.each_squarefree() -> Obj
Return the
Aliases: squarefree_each
ecm_factor
Number.ecm_factor() -> Obj
Return the
ei
Number.ei() -> Obj
Return the
Aliases: eint
erf
Number.erf() -> Obj
Return the
erfc
Number.erfc() -> Obj
Return the
euler
Number.euler() -> Obj
Return the
Aliases: euler_number
euler_polynomial
Number.euler_polynomial() -> Obj
Return the
exp
Number.exp() -> Obj
Return the
exp10
Number.exp10() -> Obj
Return the
exp2
Number.exp2() -> Obj
Return the
exp_mangoldt
Number.exp_mangoldt() -> Obj
Return the
expmod
Number.expmod() -> Obj
Return the
Aliases: powmod
factor
Number.factor() -> Obj
Return the
Aliases: factors
factor_exp
Number.factor_exp() -> Obj
Return the
Aliases: factors_exp
factorialmod
Number.factorialmod() -> Obj
Return the
factorial_power
Number.factorial_power() -> Obj
Return the
Aliases: factorial_valuation
factorial_sum
Number.factorial_sum() -> Obj
Return the
Aliases: left_factorial
factor_map
Number.factor_map() -> Obj
Return the
factor_prod
Number.factor_prod() -> Obj
Return the
Aliases: factors_prod
factor_sum
Number.factor_sum() -> Obj
Return the
Aliases: factors_sum
falling_factorial
Number.falling_factorial() -> Obj
Return the
faulhaber
Number.faulhaber() -> Obj
Return the
Aliases: faulhaber_sum
faulhaber_polynomial
Number.faulhaber_polynomial() -> Obj
Return the
fermat_factor
Number.fermat_factor() -> Obj
Return the
fib
Number.fib() -> Obj
Return the
Aliases: fibonacci
fibmod
Number.fibmod() -> Obj
Return the
Aliases: fibonacci_mod, fibonaccimod
flip
Number.flip() -> Obj
Return the
Aliases: reverse
flipbit
Number.flipbit() -> Obj
Return the
floor
Number.floor() -> Obj
Return the
flt_factor
Number.flt_factor() -> Obj
Return the
gcd
Number.gcd() -> Obj
Return the
gcdext
Number.gcdext() -> Obj
Return the
geometric_sum
Number.geometric_sum() -> Obj
Return the
gpf
Number.gpf() -> Obj
Return the
hamdist
Number.hamdist() -> Obj
Return the
harm
Number.harm() -> Obj
Return the
Aliases: harmfrac, harmonic, harmonic_number
harmreal
Number.harmreal() -> Obj
Return the
hermite_H
Number.hermite_H() -> Obj
Return the
Aliases: hermiteH, hermite_polynomial_H, hermite_polynomialH
hermite_He
Number.hermite_He() -> Obj
Return the
Aliases: hermiteHe, hermite_polynomial_He, hermite_polynomialHe
holf_factor
Number.holf_factor() -> Obj
Return the
hyperfactorial
Number.hyperfactorial() -> Obj
Return the
hyperfactorial_ln
Number.hyperfactorial_ln() -> Obj
Return the
Aliases: lnhyperfactorial, hyperfactorial_log
hypot
Number.hypot() -> Obj
Return the
i
Number.i() -> Obj
Return the
iadd
Number.iadd() -> Obj
Return the
icbrt
Number.icbrt() -> Obj
Return the
ilog
Number.ilog() -> Obj
Return the
ilog10
Number.ilog10() -> Obj
Return the
ilog2
Number.ilog2() -> Obj
Return the
im
Number.im() -> Obj
Return the
Aliases: imag, imaginary
imod
Number.imod() -> Obj
Return the
imul
Number.imul() -> Obj
Return the
inf
Number.inf() -> Obj
Return the
int
Number.int() -> Obj
Return the
Aliases: to_i, to_int, trunc
inv
Number.inv() -> Obj
Return the
inverse_phi
Number.inverse_phi() -> Obj
Return the
Aliases: inverse_totient
inverse_phi_len
Number.inverse_phi_len() -> Obj
Return the
Aliases: inverse_totient_len
inverse_polygonal
Number.inverse_polygonal() -> Obj
Return the
Aliases: polygonal_inverse
inverse_psi
Number.inverse_psi() -> Obj
Return the
Aliases: inverse_dedekind_psi
inverse_psi_len
Number.inverse_psi_len() -> Obj
Return the
Aliases: inverse_dedekind_psi_len
inverse_sigma
Number.inverse_sigma() -> Obj
Return the
inverse_sigma_len
Number.inverse_sigma_len() -> Obj
Return the
inverse_uphi
Number.inverse_uphi() -> Obj
Return the
inverse_usigma
Number.inverse_usigma() -> Obj
Return the
invmod
Number.invmod() -> Obj
Return the
ipolygonal_root
Number.ipolygonal_root() -> Obj
Return the
ipolygonal_root2
Number.ipolygonal_root2() -> Obj
Return the
ipow
Number.ipow() -> Obj
Return the
ipow10
Number.ipow10() -> Obj
Return the
ipow2
Number.ipow2() -> Obj
Return the
iquadratic_formula
Number.iquadratic_formula() -> Obj
Return the
Aliases: integer_quadratic_formula
irand
Number.irand() -> Obj
Return the
iroot
Number.iroot() -> Obj
Return the
irootrem
Number.irootrem() -> Obj
Return the
is_abundant
Number.is_abundant() -> Obj
Return the
is_aks_prime
Number.is_aks_prime() -> Obj
Return the
is_almost_prime
Number.is_almost_prime() -> Obj
Return the
is_between
Number.is_between() -> Obj
Return the
is_bpsw_prime
Number.is_bpsw_prime() -> Obj
Return the
is_carmichael
Number.is_carmichael() -> Obj
Return the
is_chebyshev
Number.is_chebyshev() -> Obj
Return the
Aliases: is_chebyshev_psp, is_chebyshev_pseudoprime
is_complex
Number.is_complex() -> Obj
Return the
is_composite
Number.is_composite() -> Obj
Return the
is_congruent
Number.is_congruent() -> Obj
Return the
is_coprime
Number.is_coprime() -> Obj
Return the
is_cube
Number.is_cube() -> Obj
Return the
is_cyclic
Number.is_cyclic() -> Obj
Return the
is_ecpp_prime
Number.is_ecpp_prime() -> Obj
Return the
iseed
Number.iseed() -> Obj
Return the
is_euler_psp
Number.is_euler_psp() -> Obj
Return the
Aliases: is_euler_pseudoprime
is_even
Number.is_even() -> Obj
Return the
is_fib_psp
Number.is_fib_psp() -> Obj
Return the
Aliases: is_lucasu_psp, is_lucasU_psp, is_fibonacci_psp, is_lucasU_pseudoprime, is_fibonacci_pseudoprime
is_frobenius_psp
Number.is_frobenius_psp() -> Obj
Return the
Aliases: is_frobenius_pseudoprime
is_fundamental
Number.is_fundamental() -> Obj
Return the
is_gaussian_prime
Number.is_gaussian_prime() -> Obj
Return the
is_imag
Number.is_imag() -> Obj
Return the
is_imprimitive_carmichael
Number.is_imprimitive_carmichael() -> Obj
Return the
is_inf
Number.is_inf() -> Obj
Return the
is_int
Number.is_int() -> Obj
Return the
is_khashin_psp
Number.is_khashin_psp() -> Obj
Return the
Aliases: is_khashin_pseudoprime, is_frobenius_khashin_psp, is_frobenius_khashin_pseudoprime
is_lucas_carmichael
Number.is_lucas_carmichael() -> Obj
Return the
is_lucas_psp
Number.is_lucas_psp() -> Obj
Return the
Aliases: is_lucas_pseudoprime
is_lucasv_psp
Number.is_lucasv_psp() -> Obj
Return the
Aliases: is_lucasV_psp, is_bruckman_lucas_psp, is_lucasV_pseudoprime, is_bruckman_lucas_pseudoprime
is_mersenne_prime
Number.is_mersenne_prime() -> Obj
Return the
is_mone
Number.is_mone() -> Obj
Return the
is_nan
Number.is_nan() -> Obj
Return the
is_neg
Number.is_neg() -> Obj
Return the
Aliases: is_negative
is_ninf
Number.is_ninf() -> Obj
Return the
is_nm1_prime
Number.is_nm1_prime() -> Obj
Return the
Aliases: is_pm1_prime, is_nminus1_prime
is_np1_prime
Number.is_np1_prime() -> Obj
Return the
Aliases: is_pp1_prime, is_nplus1_prime
is_odd
Number.is_odd() -> Obj
Return the
is_odd_composite
Number.is_odd_composite() -> Obj
Return the
is_one
Number.is_one() -> Obj
Return the
is_over_psp
Number.is_over_psp() -> Obj
Return the
Aliases: is_over_pseudoprime, is_overpseudoprime
is_palindrome
Number.is_palindrome() -> Obj
Return the
Aliases: is_palindromic
is_pell_lucas_psp
Number.is_pell_lucas_psp() -> Obj
Return the
Aliases: is_pell_lucas_pseudoprime
is_pell_psp
Number.is_pell_psp() -> Obj
Return the
Aliases: is_pell_pseudoprime
is_perrin_psp
Number.is_perrin_psp() -> Obj
Return the
Aliases: is_perrin_pseudoprime
is_plumb_psp
Number.is_plumb_psp() -> Obj
Return the
Aliases: is_euler_plumb_psp, is_plumb_pseudoprime, is_euler_plumb_pseudoprime
is_polygonal
Number.is_polygonal() -> Obj
Return the
is_polygonal2
Number.is_polygonal2() -> Obj
Return the
is_pos
Number.is_pos() -> Obj
Return the
Aliases: is_positive
is_pow
Number.is_pow() -> Obj
Return the
Aliases: is_power, is_perfect_power
is_powerful
Number.is_powerful() -> Obj
Return the
is_power_of
Number.is_power_of() -> Obj
Return the
is_practical
Number.is_practical() -> Obj
Return the
is_prime
Number.is_prime() -> Obj
Return the
is_prime_power
Number.is_prime_power() -> Obj
Return the
is_primitive_root
Number.is_primitive_root() -> Obj
Return the
is_prob_prime
Number.is_prob_prime() -> Obj
Return the
is_prob_squarefree
Number.is_prob_squarefree() -> Obj
Return the
is_prov_prime
Number.is_prov_prime() -> Obj
Return the
Aliases: is_provable_prime
is_psp
Number.is_psp() -> Obj
Return the
Aliases: is_fermat_psp, is_pseudoprime, is_fermat_pseudoprime
isqrt
Number.isqrt() -> Obj
Return the
isqrtrem
Number.isqrtrem() -> Obj
Return the
is_rat
Number.is_rat() -> Obj
Return the
is_real
Number.is_real() -> Obj
Return the
is_rough
Number.is_rough() -> Obj
Return the
is_safe_prime
Number.is_safe_prime() -> Obj
Return the
is_semiprime
Number.is_semiprime() -> Obj
Return the
is_smooth
Number.is_smooth() -> Obj
Return the
is_smooth_over_prod
Number.is_smooth_over_prod() -> Obj
Return the
is_sqr
Number.is_sqr() -> Obj
Return the
Aliases: is_square, is_perfect_square
is_square_free
Number.is_square_free() -> Obj
Return the
Aliases: is_squarefree
is_stronger_lucas_psp
Number.is_stronger_lucas_psp() -> Obj
Return the
Aliases: is_extra_strong_lucas_psp, is_stronger_lucas_pseudoprime, is_extra_strong_lucas_pseudoprime
is_strong_fib
Number.is_strong_fib() -> Obj
Return the
Aliases: is_strong_fib_psp, is_strong_fibonacci, is_strong_fibonacci_psp, is_strong_fibonacci_pseudoprime
is_strongish_lucas_psp
Number.is_strongish_lucas_psp() -> Obj
Return the
Aliases: is_strongish_lucas_pseudoprime
is_strong_lucas_psp
Number.is_strong_lucas_psp() -> Obj
Return the
Aliases: is_strong_lucas_pseudoprime
is_strong_psp
Number.is_strong_psp() -> Obj
Return the
Aliases: miller_rabin, is_strong_fermat_psp, is_strong_pseudoprime, is_strong_fermat_pseudoprime
is_super_psp
Number.is_super_psp() -> Obj
Return the
Aliases: is_super_pseudoprime, is_superpseudoprime
is_totient
Number.is_totient() -> Obj
Return the
isub
Number.isub() -> Obj
Return the
is_underwood_psp
Number.is_underwood_psp() -> Obj
Return the
Aliases: is_underwood_pseudoprime, is_frobenius_underwood_psp, is_frobenius_underwood_pseudoprime
is_zero
Number.is_zero() -> Obj
Return the
jacobi
Number.jacobi() -> Obj
Return the
jordan_totient
Number.jordan_totient() -> Obj
Return the
kronecker
Number.kronecker() -> Obj
Return the
laguerre
Number.laguerre() -> Obj
Return the
Aliases: laguerreL, laguerre_polynomial
lambda
lambda(n)
Carmichael lambda function: λ(n)
, defined as the smallest positive integer m
such that:
aᵐ ≡ 1 (mod n)
for every integer a
between 1
and n
that is coprime to n
.
Alias: carmichael_lambda.
lambert_w
Number.lambert_w() -> Obj
Return the
lcm
Number.lcm() -> Obj
Return the
legendre
Number.legendre() -> Obj
Return the
legendre_P
Number.legendre_P() -> Obj
Return the
Aliases: legendrep, legendreP, legendre_polynomial
len
Number.len() -> Obj
Return the
Aliases: size, length
lgamma
Number.lgamma() -> Obj
Return the
Aliases: gamma_abs_log
lgrt
Number.lgrt() -> Obj
Return the
li
Number.li() -> Obj
Return the
li2
Number.li2() -> Obj
Return the
liouville
Number.liouville() -> Obj
Return the
liouville_sum
Number.liouville_sum() -> Obj
Return the
ln
Number.ln() -> Obj
Return the
ln2
Number.ln2() -> Obj
Return the
lnbern
Number.lnbern() -> Obj
Return the
Aliases: bern_log, lnbernreal, bernoulli_log
lngamma
Number.lngamma() -> Obj
Return the
Aliases: gamma_log
lnsuperfactorial
Number.lnsuperfactorial() -> Obj
Return the
Aliases: superfactorial_ln, superfactorial_log
log
Number.log() -> Obj
Return the
log10
Number.log10() -> Obj
Return the
log2
Number.log2() -> Obj
Return the
logarithmic_derivative
Number.logarithmic_derivative() -> Obj
Return the
lpf
Number.lpf() -> Obj
Return the
lsb
Number.lsb() -> Obj
Return the
lucas
Number.lucas() -> Obj
Return the
lucas_factor
Number.lucas_factor() -> Obj
Return the
Aliases: lucas_miller_factor
lucas_mod
Number.lucas_mod() -> Obj
Return the
Aliases: lucasmod
lucas_U
Number.lucas_U() -> Obj
Return the
Aliases: lucasu, lucasU
lucasumod
Number.lucasumod() -> Obj
Return the
Aliases: lucasUmod
lucasuvmod
Number.lucasuvmod() -> Obj
Return the
Aliases: lucasUVmod
lucas_V
Number.lucas_V() -> Obj
Return the
Aliases: lucasv, lucasV
lucasvmod
Number.lucasvmod() -> Obj
Return the
Aliases: lucasVmod
make_coprime
Number.make_coprime() -> Obj
Return the
mangoldt
Number.mangoldt() -> Obj
Return the
max
Number.max() -> Obj
Return the
mertens
Number.mertens() -> Obj
Return the
mfac
Number.mfac() -> Obj
Return the
Aliases: mfactorial, multi_factorial
miller_factor
Number.miller_factor() -> Obj
Return the
Aliases: miller_rabin_factor
miller_rabin_random
Number.miller_rabin_random() -> Obj
Return the
min
Number.min() -> Obj
Return the
mone
Number.mone() -> Obj
Return the
motzkin
Number.motzkin() -> Obj
Return the
msb
Number.msb() -> Obj
Return the
mulmod
Number.mulmod() -> Obj
Return the
multinomial
Number.multinomial() -> Obj
Return the
nan
Number.nan() -> Obj
Return the
nd
Number.nd() -> Obj
Return the
Aliases: rd, st, th
neg
Number.neg() -> Obj
Return the
new
Number.new() -> Obj
Return the
Aliases: call
next_composite
Number.next_composite() -> Obj
Return the
next_palindrome
Number.next_palindrome() -> Obj
Return the
next_pow
Number.next_pow() -> Obj
Return the
Aliases: next_power
next_pow2
Number.next_pow2() -> Obj
Return the
Aliases: next_power2
next_prime
Number.next_prime() -> Obj
Return the
next_twin_prime
Number.next_twin_prime() -> Obj
Return the
ninf
Number.ninf() -> Obj
Return the
nok
Number.nok() -> Obj
Return the
Aliases: binomial
norm
Number.norm() -> Obj
Return the
n_primes
Number.n_primes() -> Obj
Return the
Aliases: nprimes
nu
Number.nu() -> Obj
Return the
Aliases: numerator
nude
Number.nude() -> Obj
Return the
num2perm
Number.num2perm() -> Obj
Return the
numify
Number.numify() -> Obj
Return the
of
Number.of() -> Obj
Return the
one
Number.one() -> Obj
Return the
partitions
Number.partitions() -> Obj
Return the
Aliases: partition_number
pbrent_factor
Number.pbrent_factor() -> Obj
Return the
perfect_power
Number.perfect_power() -> Obj
Return the
perfect_root
Number.perfect_root() -> Obj
Return the
permutations
Number.permutations() -> Obj
Return the
pi_k
Number.pi_k() -> Obj
Return the
Aliases: k_prime_count, almost_primepi, almost_prime_count
pm1_factor
Number.pm1_factor() -> Obj
Return the
Aliases: pminus1_factor
pn_primes
Number.pn_primes() -> Obj
Return the
pn_primorial
Number.pn_primorial() -> Obj
Return the
polygonal
Number.polygonal() -> Obj
Return the
polygonal_root
Number.polygonal_root() -> Obj
Return the
polygonal_root2
Number.polygonal_root2() -> Obj
Return the
polymod
Number.polymod() -> Obj
Return the
popcount
Number.popcount() -> Obj
Return the
Aliases: hammingweight
power_count
Number.power_count() -> Obj
Return the
Aliases: perfect_power_count
powerful
Number.powerful() -> Obj
Return the
powerful_count
Number.powerful_count() -> Obj
Return the
pp1_factor
Number.pp1_factor() -> Obj
Return the
Aliases: pplus1_factor
prev_prime
Number.prev_prime() -> Obj
Return the
prho_factor
Number.prho_factor() -> Obj
Return the
primality_pretest
Number.primality_pretest() -> Obj
Return the
prime
Number.prime() -> Obj
Return the
Aliases: nth_prime
prime_divisors
Number.prime_divisors() -> Obj
Return the
primepi
Number.primepi() -> Obj
Return the
Aliases: prime_count, count_primes
primepi_lower
Number.primepi_lower() -> Obj
Return the
Aliases: prime_count_lower
primepi_upper
Number.primepi_upper() -> Obj
Return the
Aliases: prime_count_upper
prime_power
Number.prime_power() -> Obj
Return the
prime_power_count
Number.prime_power_count() -> Obj
Return the
prime_power_divisors
Number.prime_power_divisors() -> Obj
Return the
prime_power_sigma
Number.prime_power_sigma() -> Obj
Return the
prime_power_udivisors
Number.prime_power_udivisors() -> Obj
Return the
Aliases: prime_power_unitary_divisors, unitary_prime_power_divisors
prime_power_usigma
Number.prime_power_usigma() -> Obj
Return the
prime_root
Number.prime_root() -> Obj
Return the
primes
Number.primes() -> Obj
Return the
prime_sigma
Number.prime_sigma() -> Obj
Return the
primes_sum
Number.primes_sum() -> Obj
Return the
Aliases: sum_primes
prime_udivisors
Number.prime_udivisors() -> Obj
Return the
Aliases: prime_unitary_divisors, unitary_prime_divisors
prime_usigma
Number.prime_usigma() -> Obj
Return the
prime_usigma0
Number.prime_usigma0() -> Obj
Return the
primitive_part
Number.primitive_part() -> Obj
Return the
primorial
Number.primorial() -> Obj
Return the
primorial_deflation
Number.primorial_deflation() -> Obj
Return the
primorial_inflation
Number.primorial_inflation() -> Obj
Return the
psi
Number.psi() -> Obj
Return the
Aliases: dedekind_psi
qnr
Number.qnr() -> Obj
Return the
Aliases: quadratic_nonresidue
qs_factor
Number.qs_factor() -> Obj
Return the
quadratic_formula
Number.quadratic_formula() -> Obj
Return the
rad
Number.rad() -> Obj
Return the
rad2deg
Number.rad2deg() -> Obj
Return the
ramanujan_sum
Number.ramanujan_sum() -> Obj
Return the
ramanujan_tau
Number.ramanujan_tau() -> Obj
Return the
rand
Number.rand() -> Obj
Return the
random_bytes
Number.random_bytes() -> Obj
Return the
random_maurer_nbit_prime
Number.random_maurer_nbit_prime() -> Obj
Return the
Aliases: random_nbit_maurer_prime
random_nbit_prime
Number.random_nbit_prime() -> Obj
Return the
random_nbit_strong_prime
Number.random_nbit_strong_prime() -> Obj
Return the
Aliases: random_strong_nbit_prime
random_ndigit_prime
Number.random_ndigit_prime() -> Obj
Return the
random_prime
Number.random_prime() -> Obj
Return the
random_safe_prime
Number.random_safe_prime() -> Obj
Return the
random_string
Number.random_string() -> Obj
Return the
range
Number.range() -> Obj
Return the
rat
Number.rat() -> Obj
Return the
Aliases: to_r, to_rat
rat_approx
Number.rat_approx() -> Obj
Return the
ratmod
Number.ratmod() -> Obj
Return the
re
Number.re() -> Obj
Return the
Aliases: real
reals
Number.reals() -> Obj
Return the
remdiv
Number.remdiv() -> Obj
Return the
Aliases: remove
rising_factorial
Number.rising_factorial() -> Obj
Return the
root
Number.root() -> Obj
Return the
rough_count
Number.rough_count() -> Obj
Return the
rough_part
Number.rough_part() -> Obj
Return the
round
Number.round() -> Obj
Return the
Aliases: roundf
run
Number.run() -> Obj
Return the
sec
Number.sec() -> Obj
Return the
secant_number
Number.secant_number() -> Obj
Return the
sech
Number.sech() -> Obj
Return the
seed
Number.seed() -> Obj
Return the
semiprime
Number.semiprime() -> Obj
Return the
Aliases: nth_semiprime
semiprime_count
Number.semiprime_count() -> Obj
Return the
setbit
Number.setbit() -> Obj
Return the
sgn
Number.sgn() -> Obj
Return the
Aliases: sign
sigma0
Number.sigma0() -> Obj
Return the
sin
Number.sin() -> Obj
Return the
sin_cos
Number.sin_cos() -> Obj
Return the
sinh
Number.sinh() -> Obj
Return the
smooth_count
Number.smooth_count() -> Obj
Return the
smooth_part
Number.smooth_part() -> Obj
Return the
solve_pell
Number.solve_pell() -> Obj
Return the
sopf
Number.sopf() -> Obj
Return the
sopfr
Number.sopfr() -> Obj
Return the
sqr
Number.sqr() -> Obj
Return the
sqrt
Number.sqrt() -> Obj
Return the
sqrt_cfrac
Number.sqrt_cfrac() -> Obj
Return the
sqrt_cfrac_period
Number.sqrt_cfrac_period() -> Obj
Return the
sqrt_cfrac_period_len
Number.sqrt_cfrac_period_len() -> Obj
Return the
sqrtmod
Number.sqrtmod() -> Obj
Return the
square_divisors
Number.square_divisors() -> Obj
Return the
squarefree
Number.squarefree() -> Obj
Return the
square_free_count
Number.square_free_count() -> Obj
Return the
Aliases: squarefree_count
squarefree_divisors
Number.squarefree_divisors() -> Obj
Return the
squarefree_sigma
Number.squarefree_sigma() -> Obj
Return the
squarefree_udivisors
Number.squarefree_udivisors() -> Obj
Return the
Aliases: squarefree_unitary_divisors, unitary_squarefree_divisors
squarefree_usigma
Number.squarefree_usigma() -> Obj
Return the
squarefree_usigma0
Number.squarefree_usigma0() -> Obj
Return the
square_sigma
Number.square_sigma() -> Obj
Return the
square_sigma0
Number.square_sigma0() -> Obj
Return the
square_udivisors
Number.square_udivisors() -> Obj
Return the
Aliases: square_unitary_divisors, unitary_square_divisors
square_usigma
Number.square_usigma() -> Obj
Return the
square_usigma0
Number.square_usigma0() -> Obj
Return the
squfof_factor
Number.squfof_factor() -> Obj
Return the
stirling
Number.stirling() -> Obj
Return the
Aliases: stirling1
stirling2
Number.stirling2() -> Obj
Return the
stirling3
Number.stirling3() -> Obj
Return the
subfactorial
Number.subfactorial() -> Obj
Return the
submod
Number.submod() -> Obj
Return the
subsets
Number.subsets() -> Obj
Return the
superfactorial
Number.superfactorial() -> Obj
Return the
superprimorial
Number.superprimorial() -> Obj
Return the
tan
Number.tan() -> Obj
Return the
tangent_number
Number.tangent_number() -> Obj
Return the
tanh
Number.tanh() -> Obj
Return the
times
Number.times() -> Obj
Return the
to_f
Number.to_f() -> Obj
Return the
Aliases: float, to_float
to_n
Number.to_n() -> Obj
Return the
Aliases: to_num
to_s
Number.to_s() -> Obj
Return the
Aliases: to_str
totient
Number.totient() -> Obj
Return the
Aliases: euler_phi, eulerphi, euler_totient
trial_factor
Number.trial_factor() -> Obj
Return the
tuples
Number.tuples() -> Obj
Return the
Aliases: variations
tuples_with_repetition
Number.tuples_with_repetition() -> Obj
Return the
Aliases: variations_with_repetition
udivisors
Number.udivisors() -> Obj
Return the
Aliases: unitary_divisors
uphi
Number.uphi() -> Obj
Return the
usigma
Number.usigma() -> Obj
Return the
usigma0
Number.usigma0() -> Obj
Return the
Aliases: squarefree_sigma0
valuation
Number.valuation() -> Obj
Return the
zero
Number.zero() -> Obj
Return the
znorder
Number.znorder() -> Obj
Return the
znprimroot
Number.znprimroot() -> Obj
Return the