HP Prime Program: ULAM « Next Oldest | Next Newest »

 ▼ Eddie W. Shore Posting Freak Posts: 764 Threads: 118 Joined: Aug 2007 10-02-2013, 03:34 PM ```ULAM - Using Ulam's Conjecture to determine the number of steps it takes to reduce an integer N to 1 using the following rules: If N is odd: N = 3×N+1 If N is even: N=N/2 9/24/2013 Program: EXPORT ULAM(N) BEGIN LOCAL C; PRINT(); REPEAT IF FP(N/2)==0 THEN N:=N/2; ELSE N:=3*N+1; END; C:=C+1; PRINT(N); UNTIL N==1; RETURN C; END; Examples: ULAM(69): 208, 104, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 (14 steps) ULAM(84): 42, 21, 64, 32, 16, 8, 4, 2, 1 (9 steps) ```

 Possibly Related Threads... Thread Author Replies Views Last Post Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 5,626 12-10-2013, 05:35 PM Last Post: Erwin Ried Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 2,555 12-05-2013, 03:07 PM Last Post: Carlos CM (Mexico) HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 801 11-25-2013, 11:35 AM Last Post: Joseph Ec Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 1,674 11-19-2013, 08:59 AM Last Post: Miguel Toro Prime: Program size limited to 64K? Erwin Ried 4 1,494 11-17-2013, 11:42 PM Last Post: Joseph Ec [HP-Prime] Picking elements from a List in a program Jean-Michel 3 1,448 11-15-2013, 04:16 AM Last Post: dg1969 HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 1,526 11-13-2013, 10:03 PM Last Post: BruceTTT HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,991 11-11-2013, 08:28 PM Last Post: Davi Ribeiro de Oliveira [prime] Insert a breakpoint in a program for debugging ? Olivier Lecluse 3 1,314 11-09-2013, 09:41 PM Last Post: Joseph Ec HP PRIME: Hide return value from program and swap Edit with Run vrrr 2 1,174 11-09-2013, 04:04 PM Last Post: vrrr

Forum Jump: