Jump to content

Perform Calculations until condition is met.

Hey there! I'm trying to create a little program for my calculator (Casio Prizm) to solve Linear Diophantine equations of the form ax+by=c.

 

My progress so far has been to code in a way to check if the equation has a solution (by the means of GCD). What I've done, more specifically, is check if the fractional part of the division between C and the GCD(A,B ) is different from 0. If it is, then it has no solution. If it isn't, well, it has. I've coded something like this:

If (Frac (C/GCD(A,B )≠0)

Then "No Solution"

Else

IfEnd

 

That's how I have that set up. Now, I need to do the Else part. What I need to do is Divide "A" between "B", store its quotient for later use, and then divide B by the Reminder (call it R1) of A divided B. Then, I would store the quotient of B divided R1 and use its reminder (call it R2) to divide R1, and store its quotient, etc, etc, etc. I have access to the function "Int" (Tells the quotient of the division between two numbers, for instance: 4Int2=2) and the function "Rmd" (tells the reminder, for example: 9RMD2=1). To store a result in a variable, you just add an arrow and the variable after the result: 2+2->K.

 

Now, the problems:

  • Do this while using the least amounts of variables possible. A, B and C can't be touched. I have from D through Z to store quotients.
  • I need those divisions to go on until a reminder hits 0. I'm puzzled as to how to do this in this basic language (my first attempt at coding something "serious", by the way).

Any help would be appreciated. If you happen to need any more data, I will do my best to provide it :) .

 

Cheers and thanks!!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×