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
- Quickly convert Decimal to other bases in Python
- Minimum digits to be removed to make either all digits or alternating digits same
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- 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
- Check if the sum of digits of number is divisible by all of its digits
- Find the Largest number with given number of digits and sum of digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Find the prime numbers which can written as sum of most consecutive primes
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- 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
- 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
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Paytm Interview Experience | Set 7 (Written Test Hyderabad)
- Find if n can be written as product of k numbers
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.