maths.sum_of_digits

Functions

benchmark(→ None)

Benchmark multiple functions, with three different length int values.

sum_of_digits(→ int)

Find the sum of digits of a number.

sum_of_digits_compact(→ int)

Find the sum of digits of a number

sum_of_digits_recursion(→ int)

Find the sum of digits of a number using recursion

Module Contents

maths.sum_of_digits.benchmark() None

Benchmark multiple functions, with three different length int values.

maths.sum_of_digits.sum_of_digits(n: int) int

Find the sum of digits of a number. >>> sum_of_digits(12345) 15 >>> sum_of_digits(123) 6 >>> sum_of_digits(-123) 6 >>> sum_of_digits(0) 0

maths.sum_of_digits.sum_of_digits_compact(n: int) int

Find the sum of digits of a number >>> sum_of_digits_compact(12345) 15 >>> sum_of_digits_compact(123) 6 >>> sum_of_digits_compact(-123) 6 >>> sum_of_digits_compact(0) 0

maths.sum_of_digits.sum_of_digits_recursion(n: int) int

Find the sum of digits of a number using recursion >>> sum_of_digits_recursion(12345) 15 >>> sum_of_digits_recursion(123) 6 >>> sum_of_digits_recursion(-123) 6 >>> sum_of_digits_recursion(0) 0