Let consider the case x=954
954 -> 122 -> 9 -> 81 -> 65 -> 61 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37
So 37 is seen twice, it should end up with 37, no ?
No, 89 shows up before 37 does
By the description at ProjectEuler.net, it seems M is correct in their statement. The description there reads: "continuously [...] form a new number until it [that number just formed] has been seen before." That is exactly what M has done. Project Euler says furthermore: "[...] EVERY starting number will eventually arrive at 1 or 89." That is _not_ the same as stating: "this number chain always terminates with either 1 or 89". The key difference is in "arrives at" (the number appears) versus "terminates with" (the number is the first to appear twice in the sequence). In M's example, the sequence truly 'terminates with' 37 (as M said), but before it terminates the sequence had 'arrived at' 89.
This solution requires Neural Network Toolbox
Remove the air bubbles
Multiply a column by a row
Change the sign of even index entries of the reversed vector
sum of non-primes
Find the nearest integer
Cache me Outside
Generate N equally spaced intervals between -L and L
Multiples of a Number in a Given Range
Test if a Number is a Palindrome without using any String Operations
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office