Pythagoras Numbers [Fx-5800P] - Your Projects - Universal Casio Forum

Jump to content



Photo
- - - - -

Pythagoras Numbers [Fx-5800P]

fx-5800P

  • Please log in to reply
No replies to this topic

#1 Krtyski

Krtyski

    Casio Freak

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

  • Calculators:
    FX-502P, FX-602P, FX-603P,
    fx-4000P, fx-7000G,
    fx-4500P, fx-4800P
    fx-5800P,
    CFX-9850G,
    CFX-9850GC PLUS
    fx-9860G,
    fx-9860G AU,
    fx-9860G Slim
    fx-9860GII SD,
    fx-9860GII-2,
    fx-9860GII-2 SD,
    fx-CG20, fx-CG50,
    fx-CP400
    fx-9860GIII
    fx-9750GIII
    fx-7400GIII

Posted 02 December 2014 - 02: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).
Pytha1_convert_20141130130800.jpg
 
Hit EXE key, next Pythagoras numbers are displayed. Let me call this is 'step mode'.
Pytha2_convert_20141130130821.jpg
 
Long press EXE 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 - 02: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