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
- Count of integers in a range which have even number of odd digits and odd number of even digits
- 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
- Maximize the given number by replacing a segment of digits with the alternate digits given
- 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
- 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
- Find the average of k digits from the beginning and l digits from the end of the given number
- Check if the sum of digits of number is divisible by all of its digits
- Number of digits in the nth number made of given four digits
- Find count of digits in a number that divide the number
- Print a number strictly less than a given number such that all its digits are distinct.
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.