Given an integer N, the task is to find the sum of the digits of the number N written in all the bases from 2 to N / 2.
Input: N = 6
In base 2, 6 is represented as 110.
In base 3, 6 is represented as 20.
Sum = 1 + 1 + 0 + 2 + 0 = 4
Input: N = 8
- For every base from 2 to (n / 2) calculate the digits of n in the particular base with the following:
- Calculate the remainder on dividing n by base and the remainder is one of the digits of n in that base.
- Add the digit to the sum and update n as (n = n / base).
- Repeat the above steps while n > 0
- Print the sum calculated in the previous steps.
Below is the implementation of the above approach:
- Sum of digits written in different bases from 2 to n-1
- Check if a number can be written as a sum of 'k' prime numbers
- Check if a number can be written as sum of three consecutive integers
- Quickly convert Decimal to other bases in Python
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Minimum number of digits to be removed so that no two consecutive digits are same
- Find the Largest number with given number of digits and sum of digits
- Number of digits in the nth number made of given four digits
- Count number of digits after decimal on dividing a number
- Find maximum number that can be formed using digits of a given number
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Print a number strictly less than a given number such that all its digits are distinct.
- Find the smallest number whose digits multiply to a given number n
- Number of digits to be removed to make a number divisible by 3