Post Reply 
Convert Foster Netowrk to Cauer
06-04-2024, 09:08 PM (This post was last modified: 06-06-2024 08:52 AM by carey.)
Post: #6
RE: Convert Foster Netowrk to Cauer
(06-03-2024 01:48 PM)KeithB Wrote:  Which uses "Euclid Long Division", is this something I can do on the Prime?

For whatever it's worth, here's ChatGPT's response to a request to write code for the HP Prime's PPL programming language to implement "Euclidean long division."

Code:

EXPORT EuclideanLongDivision()
BEGIN
 LOCAL startTime, endTime, elapsedTime;
 LOCAL dividend, divisor, quotient, remainder;
  
  // Input dividend and divisor
  INPUT(dividend, "Euclidean Long Division", "Enter the dividend:");
  INPUT(divisor, "Euclidean Long Division", "Enter the divisor:");
  
  // Record the start time
  startTime := TICKS;

  // Check for zero divisor
  IF divisor == 0 THEN
    MSGBOX("Error: Divisor cannot be zero.");
    RETURN;
  END;

  // Initialize quotient and remainder
  quotient := 0;
  remainder := dividend;
  
  // Perform Euclidean long division
  WHILE remainder >= divisor DO
    remainder := remainder - divisor;
    quotient := quotient + 1;
  END;
  
 // Record the end time
  endTime := TICKS;

  // Calculate the elapsed time
  elapsedTime := endTime - startTime;

  // Display the result
  PRINT("Quotient: " + quotient);
  PRINT("Remainder: " + remainder);
  PRINT("Elapsed time: " + elapsedTime + " milliseconds");
  MSGBOX("Quotient: " + quotient + "\nRemainder: " + remainder +
 "\nElapsed time: " + elapsedTime + " milliseconds" );
END;

"To use this code:

1. Open the Program Editor on your HP Prime calculator.
2. Create a new program and name it `EuclideanLongDivision`.
3. Copy and paste the code above into the Program Editor.
4. Save the program.
5. Run the program, and it will prompt you to enter the dividend and the divisor. The quotient and remainder will be displayed as the result.

This code checks for division by zero and performs the Euclidean long division, displaying the quotient and the remainder at the end."

Good luck!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Convert Foster Netowrk to Cauer - KeithB - 06-03-2024, 01:48 PM
RE: Convert Foster Netowrk to Cauer - carey - 06-04-2024 09:08 PM
RE: Convert Foster Netowrk to Cauer - jte - 06-07-2024, 03:09 AM



User(s) browsing this thread: 25 Guest(s)