The following warnings occurred:
Warning [2] Undefined array key 84086 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84094 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84099 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84151 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84161 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84099 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 84161 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





lcm program on hp 33s



#6

does anybody know a program for finding the lcm of two numbers on the hp33s (or hp 32s or 32sii)?


#7

Hi Kevin,
I just banged out this very simple, brute force program for a 33s that seems to work. Enter yor two arguments into the X and Y stack registers and XEQ L. The LCM will show in the display when finished. The bigger the arguments and the higher the LCM, the longer it takes. I put in 5000 and 5002 and it took about a munute to return an lcm of 12505000. 50 and 57 took 3 seconds to return 2850. Best regards, Hal

The program:

lblL

x>y?

x<>y

stoA

x<>y

stoB

2

stoC

lblO

rclC

rclB

*

rclA

/

FP (fractional part)

x=0?

gtoQ

1

sto+C

gtoO

lblQ

rclC

rclB

*

rtn


#8

Actually the program I submitted in the posting above was predicated on the assumption that the LCM has to be at least twice the larger argument, which is actaully not true (my bad)...the LCM could be the larger argument itself. Easy fix...just change line seven to 1.


Hal :)

#9

Here are LCM and GCD routines for the 32SII/33S that I came up with. Note that LCM(m,n)= m x n / GCD(m,n) and LCM is computed here using Euclid's method. It's really fast, worst case is on the order of log base 2 of the smaller of m, n.

LCM: call with m,n in x,y return with LCM in x
uses: A, B, x,y,z,t

L01 LBL L
L02 STO A
L03 x<>y
L04 STOx A
L05 XEQ G
L06 RCL A
L07 x<>y
L08 /
L09 RTN

GCD: call with m,n in x,y return with GCD in x
uses: B, x,y,z,t

G01 LBL G
G02 x>y?
G03 x<>y
G04 STO B
G05 0 | these 7 instructions are just
G06 ENTER | to compute y mod x. On a 33S
G07 CMPLX+ | You can replace these with
G08 / | the single instruction:
G09 IP | RMDR
G10 x |
G11 - |
G12 RCL B
G13 x<>y
G14 x>0?
G15 GTO G
G16 RCL B
G17 RTN


#10

Hi, Katie:

In your 1st routine, namely:

      L01 LBL L
L02 STO A
L03 x<>y
L04 STOx A
L05 XEQ G
L06 RCL A
L07 x<>y
L08 /
L09 RTN
you can save an additional step by replacing the final
      RCL A, X<>Y, / 
by the simpler:
      L06 STO/ A
L07 X<> A
which is one step shorter, slightly faster, and leaves the GCD in A and the LCM in X. Or you can simply use
      L07 RCL A
instead of
      L07 X<> A
to get the GCD in Y and the LCM in X, also one step shorter.

Best regards from V.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,617 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Maximum number of program steps in HP-42S, 33S, and 35S? Walter B 3 1,609 12-18-2012, 03:44 PM
Last Post: Eric Smith
  Program Coding Sheets for 33s/35s Matt Agajanian 6 2,099 03-03-2012, 04:03 PM
Last Post: David Hayden
  HP-41 MCODE: Making an MCODE program call another MCODE program Geir Isene 10 2,774 01-13-2008, 05:58 AM
Last Post: Raymond Del Tondo
  HP 33s: Addressing registers at the "Top" of the program list. Ted Madson 0 667 10-23-2007, 05:11 PM
Last Post: Ted Madson
  Program format from 33s to 35s romeo_charlie 10 2,647 09-16-2007, 05:02 PM
Last Post: Paul Dale
  17b2+ solver and the GCD/LCM formula (Don?) Gene Wright 25 4,978 08-10-2007, 12:50 PM
Last Post: Vincze
  Program Loss in HP-33S Ed Look 3 1,198 04-09-2007, 10:21 PM
Last Post: Ed Look
  33s: parentheses within program Adam Price 9 2,586 02-24-2007, 09:13 PM
Last Post: bill platt
  Integration Times "Old" 33s vs "New" 33s John Smitherman 21 5,084 12-14-2005, 12:04 AM
Last Post: Karl Schneider

Forum Jump: