Post Reply 
HP 41C Pollard Brent Integer Factorization
07-04-2014, 07:07 PM
Post: #1
HP 41C Pollard Brent Integer Factorization
I don't know if anyone did this in the dark ages, but here's my try at this factorizing method.

POBR has 2 sub-programmes, see below.

POBR takes a composite integer from the stack & returns one integer factor.

0. LBL POBR
1. STO 01
2. CHS
3. STO 00
4. CLX
5. STO 02
6. LBL 02
7. SIGN
8. ST+ 02
9. STO 04
10. STO 05
11. 2
12. LBL 00
13. RCL 04
14. STO 05
15. RDN
16. STO 03
17. LBL 03
18. XEQ SQM
19. RCL 02
20. +
21. STO Y
22. RCL 03
23. –
24. RCL 01
25. XEQ GCF
26. 1
27. X≠Y?
28. GTO 01
29. RCL Z
30. DSE 05
31. GTO 03
32. RCL 04
33. RCL X
34. +
35. STO 04
36. STO 05
37. RDN
38. LBL 04
39. XEQ SQM
40. RCL 02
41. +
42. DSE 05
43. GTO 04
44. GTO 00
45. LBL 01
46. R↓
47. RCL 01
48. X<>Y
49. X=Y?
50. GTO 02
51. BEEP
52. END

SQM returns the square of the X register modulo register 01.

0. LBL SQM
1. STO Y
2. 1E5
3. MOD
4. STO Z
5. –
6. ENTER
7. X^2
8. RCL 00
9. MOD
10. X<>Y
11. R↑
12. ST* T
13. *
14. RCL 01
15. MOD
16. STO 06
17. RCL L
18. -
19. RCL 06
20. +
21. RCL 01
22. MOD
23. +
24. RCL 00
25. MOD
26. +
27. RCL 01
28. MOD
29. END

GCF returns the greatest common divisor of registers X & Y.

0. LBL GCF
1. LBL 00
2. MOD
3. LASTX
4. X<>Y
5. X≠0?
6. GTO 00
7. RDN
8. ABS
9. END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 41C Pollard Brent Integer Factorization - Gerald H - 07-04-2014 07:07 PM



User(s) browsing this thread: 1 Guest(s)