Jump to content



Photo
- - - - -

Prime factorization for fx-5800P

fx-5800P

  • Please log in to reply
2 replies to this topic

#1 Tritonio

Tritonio

    Casio Addict

  • Members
  • PipPipPip
  • 66 posts
  • Gender:Male

  • Calculators:
    fx-5800P, fx-991ES+, fx-991EX, HP Prime, fx-9750GIII

Posted 13 July 2021 - 02:12 PM

Yet another program to do prime factorization for any number. Not the fastest, not the slowest, if there's anything interesting about it is that there is zero explicit primality checks. It's just that the way it extracts factors happens to extract primes only.

"NUMBER"?I
I➔A
A≤1 Or Int(A)≠A⇒Stop
2➔P
0➔C
Lbl 1
 A÷P➔N
 If Int(N)=N:Then
  C+1➔C
  N➔A
 Else
  If C>0:Then
   Cls
   Locate 1,2,P
   Int(log(P))+2➔O
   Locate O,2,"xx"
   Locate 0+2,2,C◢
   A=1⇒Stop
  IfEnd
  P+2>√(A)⇒A-2➔P
  P=2⇒1➔P
  P+2➔P
  0➔C
  Cls
  Locate 1,1,Int(100×P÷√(A))
 IfEnd
Goto 1

Edited by Tritonio, 15 July 2021 - 06:38 PM.


#2 Krtyski

Krtyski

    Casio Freak

  • Members
  • PipPipPipPip
  • 128 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 31 July 2021 - 08:44 AM

Hi Tritonio

 

One of my personal project was how to make faster prime factoring in Casio calculators including fx-5800P.

I was so impressed by a post in UFC by secutor, it is so fast.

 

At this moment I still could not find any faster algorithm yet. So I tried make this faster for not only fx-5800P but also other graphing calculators using not only Casio basic but also C.Basic and Casio Python. I also tried to accept 15 digits input on C.Basic and Casio Python.

 

Anyway, just for your interest, let me introduce fastest prime factoring program (FACTOR-F2) running on fx-5800P. (I'm not sure you are interested in this...)

 

Download Link of FACTOR-F2

 

Prime Factoring of 7,849,516,203 (= 3 x 9811 x 88897) takes rather long time. It's about 101 sec with FACTOR-F2.

secutor's original programs gives 111 sec. FACTOR-F2 is about 9% faster than original.

This file size is rather big:

- FACTOR-F2: 21,456 bytes

- WFSUB (same as original): 147 bytes

Totality 21,603 bytes is required in 28,432 bytes memory space of fx-5800P. 

 

Detailed description how to make this is here in Japanese but using Google translate may help, I hope.


Edited by Krtyski, 31 July 2021 - 09:04 AM.


#3 Hlib2

Hlib2

    Casio Freak

  • Members
  • PipPipPipPip
  • 111 posts
  • Gender:Male
  • Location:Ukraine
  • Interests:industrial electronics,
    graphing calculators

  • Calculators:
    fx-9860gii-2, afx-2.0+
    fx-9750gii, fx-9750g+
    cfx-9850gb+, graph25
    fx-991DE_X, fx-991ES+
    ti-83+, ti-83+_SE, ti-85
    ti-voyage200, graph100+

Posted Yesterday, 07:47 PM

Here is a simple algorithm for CASIO graphic calculators (the version for C. BASIC is shown).
`#CBDBL
Lbl_0:"INPUT_N="?➝A:Goto_2
Lbl_1:2◢
A÷2➝A:A=1⇒Goto_9
Lbl_2:MOD(A,2)=0⇒Goto_1:3➝B
Lbl_3:√A+1➝C
Lbl_4:B≥C⇒Goto_8:MOD(A,B)=0⇒Goto_7
Lbl_5:B+2➝B:Goto_4
Lbl_7:B◢
A÷B➝A:Goto_3
Lbl_8:A◢
Lbl_9:"END":Goto_0
Time (for ver.2.45 build 20):
7 849 516 203 = 3×3×9 811×88 897 (1.9_sec)
9 000 000 065 = 3×3×1 000 000 007 (5.5_sec)

Edited by Hlib2, Yesterday, 07:48 PM.






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