- #1
ron_jay
- 81
- 0
Hi
Lets see...I got this interesting program: To Find the smallest number which when put together with its square as a single number has the digits 1-9 exactly once i.e. it does not have a 0 in it.
Initial Observations:
1.The first thing to see is that the conglomerated no. should have only nine digits.
2.The method to put the two number together is:
number + (10*no. of digits in its square)+ the square
3.The sum of the digits will always be 45
4.the absolute(modulus) difference between adjacent digits in the cong.. no. has to be >0
5.There must be an infinite loop which will be made to break when the number is found
Ok this is my list of ways...now I can't figure out how to use these conditions at once.Perhaps we could use arrays, but I want the code to be as simple and intelligent as possible.Find the number.
Lets see...I got this interesting program: To Find the smallest number which when put together with its square as a single number has the digits 1-9 exactly once i.e. it does not have a 0 in it.
Initial Observations:
1.The first thing to see is that the conglomerated no. should have only nine digits.
2.The method to put the two number together is:
number + (10*no. of digits in its square)+ the square
3.The sum of the digits will always be 45
4.the absolute(modulus) difference between adjacent digits in the cong.. no. has to be >0
5.There must be an infinite loop which will be made to break when the number is found
Ok this is my list of ways...now I can't figure out how to use these conditions at once.Perhaps we could use arrays, but I want the code to be as simple and intelligent as possible.Find the number.