Write a recursive function that, given two natural numbers n and b, returns true if and only if n has three or more equal consecutive digits when expressed in base b.
For example, the number 44344 does not have three equal consecutive digits in base 10. By contrast, 159 in ternary is 12220, so it does have three equal consecutive digits in base 3.
Precondition
It holds 0 ≤ n ≤ 109 and 2 ≤ b ≤ 100.
Interface
C++ | bool three_equal_consecutive_digits(int n, int b); |
C | int three_equal_consecutive_digits(int n, int b); |
Java | public static boolean three_equal_consecutive_digits(int n, int b); |
Python | three_equal_consecutive_digits(n, b) # returns bool |
three_equal_consecutive_digits(n: int, b: int) -> bool |
Observation You only need to submit the required procedure; your main program will be ignored.