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
- Find the Largest number with given number of digits and sum of digits
- Minimum number of digits to be removed so that no two consecutive digits are same
- Number of digits in the nth number made of given four digits
- Build Lowest Number by Removing n digits from a given number
- Print a number strictly less than a given number such that all its digits are distinct.
- Find count of digits in a number that divide the number
- Number of digits to be removed to make a number divisible by 3
- Find maximum number that can be formed using digits of a given number
- Find the smallest number whose digits multiply to a given number n
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.