- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this problem, we are given two positive numbers N and M. Our task is to *find the M-th number whose repeated sum of digits of a number is N. *

**Problem description: **Here, we need to find the Mth number whose sum of digits till the sum becomes single digit is equal to N.

**Let’s take an example to understand the problem, **

**Input: **N = 4 M = 6

**Output: **49

A simple solution of the problem, is by finding all numbers and count the number whose sum of digits is N, and return m-th number.

Another solution to the problem is using formula to find M-th number whose sum of digits is equal to N,

*M-th number = (m-1)*9 + N*

#include <bits/stdc++.h> using namespace std; int main() { int n = 4, m = 6; int mNumber = (m - 1) * 9 + n; cout<<m<<"-th number whose repeated sum of digits of a number is "<<n<<" is "<<mNumber; return 0; }

6-th number whose repeated sum of digits of a number is 4 is 49

- Related Questions & Answers
- n-th number whose sum of digits is ten in C++
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M in C++
- Find a Number X whose sum with its digits is equal to N in C++
- Recursive sum of digits of a number formed by repeated appends in C++
- Repeated sum of Number’s digits in JavaScript
- Find smallest number with given number of digits and sum of digits in C++
- N-th root of a number in C++
- C++ program to find largest or equal number of A whose sum of digits is divisible by 4
- Find sum of digits in factorial of a number in C++
- Find the Largest number with given number of digits and sum of digits in C++
- Find n-th Fortunate Number in C++
- Program to count number of consecutive lists whose sum is n in C++
- Minimum number of squares whose sum equals to given number n
- Maximum sum and product of the M consecutive digits in a number in C++
- Number of pairs whose sum is a power of 2 in C++

Advertisements