Question: code in java
In NASA, two researchers, Mathew and John, started their work on a new planet, but while practicing research they faced a mathematical difficulty. In order to save the time they divided their work.
So scientist Mathew worked on a piece and invented a number computed with the following formula:
T(n) = n(n+1)/2 These numbers are called Mathew numbers.
And scientist John invented another number which is built by adding the squares of its digits. Doing this perpetually, the numbers will end in 1 or 4. If a positive integer ends with 1, then it is called John number. Example of John numbers is:
13 = 1^2 + 3^2 = 1+9 = 10 (Step : 1). 10 = 1^2 + 0^2 = 1+0 = 1 (Step : 2), iteration ends in Step 2 since number ends with 1. Help Mathew and John combine their research work by finding out number in a given range that satisfies both properties?