# Pythagoras Numbers [Fx-5800P]

fx-5800P

No replies to this topic

### #1 Krtyski

Krtyski

• Members
• 88 posts
• Gender:Male
• Location:Tokyo, Japan
• Interests:programming, smooth Jazz and 4-wheel driving.

• Calculators:
FX-502P, FX-602P, fx-603P,
fx-4500P, fx-5800P,
fx-9860GII-2(SH4A),
fx-9860GII SD,
fx-CG20,
fx-CG50

Posted 02 December 2014 - 03:59 AM

Debugged

Just for fun, I wrote Pythagoras Numbers finding program with fx-5800P.

Pythagras numbers (a, b, c) are from a2 + b2 = C2 and a, b and c are given by followings;

a = (m2 - n2)/2, b = nm, c = (m2 + n2)/2
where m and n are odd and prime numbers each other, m > n and the greatest common divisor of (a, b, c) is 1.

When start this program, it displays first Pythagoras numbers (4, 3, 5).

Hit key, next Pythagoras numbers are displayed. Let me call this is 'step mode'.

Long press key will let you get in 'continuous mode' then Pythagoras numbers are continuously displayed, see video of the continuous mode.

In the continuous mode, press  key you can go back to 'step mode'.

One of my friends ported this program to fx-9860GII and fx-cg10 (just modified keycodes with Getkey command) and compared its speed. fx-9860GII displays faster with just a factor of 2, surprisingly fx-cg10 displays almost same speed as fx-5800P.

I realized we should take account of display speed for rating of calcs.

Source code of "PYTHAGORAS" for fx-5800P (debugged);

```3->M:1->1:1->D:1->E
Locate 1,2,"A="
Locate 1,3,"B="
Locate 1,4,"C="

Lbl 0

E=0=>Locate 7,1,"(-):Stop"
(M^2-N^2)÷2->A
MN->B
(M^2+N^2)÷2->C
Locate 1,1,D
Locate 3,2,"              "
Locate 3,2,A
Locate 3,3,"              "
Locate 3,3,B
Locate 3,4,"              "
Locate 3,4,C

Getkey=57=>1->E
0->K
While Getkey=47
Isz K:K=7=>Break
WhileEnd:K=7=>0->E

E=1=>Locate 7,1,"EXE:Next"◢

Do
N-2->N
If N<0:Then
M+2->M:M-2->N
IfEnd
N=1->Break
LpWhile Frac(M+N)=0
Isz D
Goto 0
```

Edited by Krtyski, 07 December 2014 - 03:27 AM.

### Also tagged with one or more of these keywords: fx-5800P

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users