I recently had reason to learn how to program my 15c (LE), and had heard that Project Euler is a good way to familiarize oneself with a new programming language/environment. Problems 1 and 2 were trivial, but I had fun with problem 3, finding the largest prime factor of a number. Unfortunately the actual number given is two digits too long for the 15c (600851475143).
To use, key the number to test into the x register then run the program. When the program has finished the largest prime factor will be in the x register. As I'm new to programming the 15c, I'd love any advice, and be interested in more efficient solutions (both speed and size improvements) if anyone is interested.
Listing
001-42,21,11 f LBL A
002- 44 0 STO 0
003- 2 2 Try 2 and 3 first
004- 44 25 STO I
005- 32 1 GSB 1
006- 3 3
007- 44 25 STO I
008- 32 1 GSB 1
009- 5 5 Start on 5
010- 44 25 STO I011-42,21, 0 f LBL 0 Main loop
012- 32 1 GSB 1
013- 2 2
014-44,40,25 STO + I
015- 32 1 GSB 1
016- 4 4
017-44,40,25 STO + I
018- 22 0 GTO 0019-42,21, 1 f LBL 1 Check factor in I
020- 45 0 RCL 0
021- 11 SQRT
022- 45 25 RCL I
023-43,30, 7 g TEST 7 Factor in I > square root of what we have left
024- 22 2 GTO 2 So we're done
025- 45 0 RCL 0
026- 34 x<>y
027- 10 /
028- 42 44 f FRAC
029- 43 20 g x=0 Even division
030- 22 3 GTO 3 So do the division and check again
031- 43 32 g RTN Otherwise, on to next factor032-42,21, 2 f LBL 2 Success, display answer
033- 45 0 RCL 0
034- 31 R/S035-42,21, 3 f LBL 3 Store remaining number and try factor again
036- 43 36 g LSTx
037- 44 0 STO 0
038- 22 1 GTO 1