maths.recursive_digit_sum¶
The super digit problem is defined as follows: Given an integer n represented as a string and an integer k, the goal is to find the super digit of the number formed by concatenating the integer n k times.
The super digit of a number is defined recursively: - If the number has only one digit, that digit is the super digit. - Otherwise, the super digit is the super digit of the sum of its digits.
For example, for n = “9875” and k = 4, the concatenated number is: super_digit(9875987598759875), which can be reduced by summing its digits.
Attributes¶
Functions¶
|
Computes the super digit of a number formed by concatenating |
Module Contents¶
- maths.recursive_digit_sum.super_digit(n_str: str, repetitions: int) int¶
Computes the super digit of a number formed by concatenating n_str repeated times.
Parameters: n_str (str): The string representation of the integer. repetitions (int): The number of times to concatenate n_str.
Returns: int: The super digit of the concatenated number.
>>> super_digit("148", 3) 3 >>> super_digit("9875", 4) 8 >>> super_digit("123", 3) 9
- maths.recursive_digit_sum.first_multiple_input¶