maths.persistence

Functions

additive_persistence(→ int)

Return the persistence of a given number.

multiplicative_persistence(→ int)

Return the persistence of a given number.

Module Contents

maths.persistence.additive_persistence(num: int) int

Return the persistence of a given number.

https://en.wikipedia.org/wiki/Persistence_of_a_number

>>> additive_persistence(199)
3
>>> additive_persistence(-1)
Traceback (most recent call last):
    ...
ValueError: additive_persistence() does not accept negative values
>>> additive_persistence("long number")
Traceback (most recent call last):
    ...
ValueError: additive_persistence() only accepts integral values
maths.persistence.multiplicative_persistence(num: int) int

Return the persistence of a given number.

https://en.wikipedia.org/wiki/Persistence_of_a_number

>>> multiplicative_persistence(217)
2
>>> multiplicative_persistence(-1)
Traceback (most recent call last):
    ...
ValueError: multiplicative_persistence() does not accept negative values
>>> multiplicative_persistence("long number")
Traceback (most recent call last):
    ...
ValueError: multiplicative_persistence() only accepts integral values