## Perfect pythagorasEdit

We all know the formula Pythagoras created: a²+b²=c². A perfect pythagoras is a situation in which the a, the b and the c are whole numbers. The first one, you might know this one, is 3²+4²=5². However, there are more of those. Some are factorisations of the simplest version, for example 6²+8²=10². And there are complete irregular ones, such as 12²+5²=13².

## Code analysisEdit

Create a new program. I call it PERFPYTH

Program:PERFPYTH

First of all, we'd like to make it MirageOS compatible.

:"Perfect pythagoras

First, like almost every program:

ClrHome

Let's just display the formula:

Disp " a²+b²=c² "

Then, we want to define the range, in which the calculator must search.

Disp " Define range: " Input "Begin of a:",D Input "End of a:",E Input "Begin of b:",F Input "End of b:",G

Now, that's done, the calculator can begin searching.

ClrHome 1→X

X is going to be used to determine where the calculator must display the things he found.

For(A,D,E) For(B,F,G)

This will make the calculator count in the defined fange.

√(A²+B²)→C

This executes the formula, and it stores the output in C.

If fPart(C)=0:Then

If the part after the . equals 0, then...

Output(X,1,A) A→H 0→I Repeat H<1 H/10→H I+1→I End Output(X,I+1,"²+") Output(X,I+3,B) B→J 0→K Repeat J<1 J/10→J K+1→K End Output(X,I+K+3,"²=") Output(X,I+K+5,C) C→L 0→M Repeat L<1 L/10→L M+1→M End Output(X,I+K+M+5,"²")

This displays the actual formula. It uses Repeat to determine how many digits whether the A the B or the C consists of. You could use a very large If-loop aswell, but that involves many more lines of programming.

X+1→X

This makes sure the next found formula is being displayed at the next line.

If X=9:Then Pause X-8→X ClrHome End

This makes sure that the program pauses when there have been displayed 8 formulas. After you press enter, the screen is cleared, and the new found formulas are displayed at the top.

End End End

This ends the if-loop, and both for-loops.

Pause

Just before the end, this is needed, because otherwize the "Done" and the cursor delete some of the formulas.

## Extra informationEdit

Since I do not speak English nativly, I'd first of all like you to correct any spelling/grammar mistakes. Secondly, I'd wanna tell you that it can take the calculator a very long time, when you for example have a range of 1 to 100. If you wanna stop the program before it has ended, press ON. Lastly, do notice you can archive this program and open it with MirageOS. It saves space in your RAM memory.