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
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Check if a number can be written as sum of three consecutive integers
- Check if a number can be written as a sum of 'k' prime numbers
- Find the Largest number with given number of digits and sum of digits
- Find the average of k digits from the beginning and l digits from the end of the given number
- Minimum number of digits to be removed so that no two consecutive digits are same
- Check if the sum of digits of number is divisible by all of its digits
- Sum of the digits of square of the given number which has only 1's as its digits
- Number of digits in the nth number made of given four digits
- Find the number of positive integers less than or equal to N that have an odd number of digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.