edit: Case Closed, There was an error in my actionscript that produced the wrong numbers for adding when the numbers contain leading zeros. (see in posts below)
I recently read up on this whole 196 algorithm thing about palindrome numbers... I am very confused. People say that there have been programs built to calculate out this sequence and that no one has been able to find a palindrome that this number produces when applied to the algorithm... Being the person I am, I went out and wrote a quick program in acitonscript.. Within about 0.8 seconds it returned a result... I don't understand, am I doing it wrong or something? Why is everyone saying it has been calculated out to millions of digits with no result when my computer is showing a result after only a few results???
Here is what my code returned:
196 + 691 = 887
887 + 788 = 1675
1675 + 5761 = 7436
7436 + 6347 = 13783
13783 + 38731 = 52514
52514 + 41525 = 94039
94039 + 93049 = 187088
187088 + 880781 = 1067869
1067869 + 9687601 = 10755470
10755470 + 07455701 = 12745039
12745039 + 93054721 = 105799760
105799760 + 067997501 = 173797261
173797261 + 162797371 = 336594632
336594632 + 236495633 = 573090265
573090265 + 562090375 = 1135180640
1135180640 + 0460815311 = 1595995951
As you can see the final result is a palindrome?
What am I doing wrong?
Ahh! I know, but the theory also lists a few numbers that have been found to not have a palindrome appear. Even after millions of reverse-then-add algorithms. The list goes: 196, 295, 394, 493, 592, 689, 691, 788, 790, 879, 887, 978, 986, 1495, 1497, 1585, 1587, 1675, 1677, 1765, 1767, 1855, 1857, 1945, 1947, 1997, etc.
People have claimed to have made programs to calculate the numbers 196 produces out to results with millions of digits and still have a palindrome not produce??? This is the whole reason it was named the 196-algorithm.
However I can't see how they can't find a palindrome for 196? It seems to 16th result.
Lychrel number - Wikipedia, the free encyclopedia
Oh, I think I know what you meant (though not what you wrote): you meant that 196 is a Lichrel nu7mber, meaning hat applying to it the 196 alg. you won't get a palindrome ever (this hasn't been proved, though)
Well, you've a mistake in line 10 in your calculations.
Tonio
AHH! I can't fix the problem ahah, Well I assume that it is a lichrel number, I tried to fix the code but it didn't work, I eventually just started the program with the correct number from line 10 and the program terminated because the numbers got to big.
I still don't know why the code doesn't work starting with 196, here it is if anyone is curious:
Actionscript 2.0:
Where "numberText" is the name of a dynamic text-field in the .fla file.Code:num = 196; _root.onEnterFrame = function() { numberText.text = num rvsString = ""; for (i=numberText.text.length; i>=0; i=i-1) { rvsString += numberText.text.charAt(i); } num2 = rvsString; if (num != num2) { num3 = num-(-num2); //subtract a negative becuase using the + operator causes the adding of strings... ex. 54 + 31 = 5431 ||*|| but ||*|| 54 - (-31) = 85 trace(num + " + " + num2 + " = " + num3); num = num-(-num2); } }
Must be an error with the way acitonscript interprets addition problems with leading zeros ..
Ex. This code:
produces this result:Code:num1 = 0000000000000010755470 + 7455701 num2 = 010755470 + 7455701 num3 = 10755470 + 000000000000007455701 num4 = 10755470 + 07455701 num5 = 0000000000000010755470 + 000000000000007455701 num6 = 010755470 + 07455701 num7 = 10755470 + 7455701 trace(num1) trace(num2) trace(num3) trace(num4) trace(num5) trace(num6) trace(num7)
9805581
9805581
12745039
12745039
4339449
4339449
18211171
They should all be equal... Anyways, case closed. Thanks forum!