Given an integer N, the task is to count all the integers less than or equal to N that follow the property where the sum of their digits raised to the power (starting from 1 and increased by 1 each time) is equal to the integer itself i.e. if D1D2D3…DN is an N digit number then for it to satisfy the given property (D11 + D22 + D33 + … + DNN) must be equal to D1D2D3…DN.
Input: N = 100
01 = 0
11 = 1
21 = 2
91 = 9
81 + 92 = 8 + 81 = 89
Input: N = 200
Approach: Initialise count = 0 and for every number from 0 to N, find the sum of digits raised to the increasing power and if the resultant sum is equal to the number itself then increment the count. Finally, print the count.
Below is the implementation of the above approach:
- Count numbers in a range having GCD of powers of prime factors equal to 1
- Count different numbers that can be generated such that there digits sum is equal to 'n'
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Count Numbers with N digits which consists of odd number of 0's
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Count Numbers with N digits which consists of even number of 0’s
- Count the number of digits of palindrome numbers in an array
- Form a number using corner digits of powers
- Count the numbers < N which have equal number of divisors as K
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Count pairs of natural numbers with GCD equal to given number
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Generate k digit numbers with digits in strictly increasing order
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Sum of first N natural numbers by taking powers of 2 as negative number
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.