Problem 58013. Find a number m such that 2m and the square of m have the same digit sum
The number  has the property that
 has the property that  and
 and  have the same digit sum. It is the seventh number, including zero, in the sequence of numbers with that property.
 have the same digit sum. It is the seventh number, including zero, in the sequence of numbers with that property. 
Write a function to find the nth term in the sequence, where n can be a vector. 
Solution Stats
Problem Comments
- 
		2 Comments
		Christian Schröder
    	on 23 Apr 2023
	
	
  	> It is the sixth number, including zero, in the sequence of numbers with that property.
Isn't it the seventh?
Also, out of curiosity, why are you disallowing persistent variables?
		ChrisR
    	on 23 Apr 2023
	
	
  	Yes, seventh--corrected, thanks. Bitten by the "off by one bug" again.
Banning persistent is to add the challenge of dealing with large numbers in Cody time. A while ago I found a quicker way to find the digit sums of a lot of numbers, and this problem was another place to exploit that method.
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
- 
         Back to basics 13 - Input variables 271 Solvers 
- 
         Create an index-powered vector 872 Solvers 
- 
         
         413 Solvers 
- 
         Find out sum of all elements of given Matrix 519 Solvers 
- 
         
         627 Solvers 
More from this Author314
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!