# HP Forums

Full Version: Bigs Factorials
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
Looking a way to duplicate a routine from my 50g wich gives all digits of an factorial, yes I say : all exacts digits, I have written this pretty smart routine :

Code:
``` 001 LBL'F' 002 IP     // To be sure it is an integer and N goes to Reg L 003 RCL L 004 DEC X 005 x=0? 006 SKIP 002 007 [times] 008 BACK 005 009 R[v] 010 RTN 011 END```

But a issue occurs ! I dont' see all digits, only for instance : 108^255.
In the past I had a program wich store results in consecutives registers (HP67)
but I dont' retrieve it.

I dont' ambitious really duplicate the program because it is in machine language compiled and I dont' know this and the autor dont' give the algoritm.

May be someone have ideas to help ?

Nice day.
This will require the implementation of multiple precision arithmetic using multiple registers. If I was going to do it, I'd most likely use integer mode and take advantage of the double precision multiplication available there.

- Pauli
Hi,
I understand. I'm going to try.
(04-11-2016 09:07 AM)ggauny@live.fr Wrote: [ -> ]Looking a way to duplicate a routine from my 50g wich gives all digits of an factorial, yes I say : all exacts digits, I have written this pretty smart routine :
(...)
But a issue occurs ! I dont' see all digits, only for instance : 108^255.

Sure. That's a standard factorial program that simply multiplies all integers from n down to 1. Like this one:

Code:
```x=0? INC X     // handle n=0 like n=1 #001      // set x=1 and leave n in Y RCLx Y    // x = x*n DSE Y     // n = n-1 and BACK 002  // jump back as long as n>0 END```

BUT: All arithmetics is done with the calculator's working precision, that is: usually 10 or 12 digits, or 16 resp. 34 on the 34s. That's all you get.

If you want more you will have to set up your own multiplication routine that returns all digits of a product, and not just the first 10, 12, 16 or 34. This is a bit tricky, but you can try the same method you would use with pencil and paper. ;-)

BTW, a simple factorial program was the very first one I ever wrote on a programmable calculator (a TI-57) or on a computer (an Apple II). ;-)

Dieter
Hi Dieter,

I'll try, without any warranty of I reach !

Me the first big computer I have see, in the office of Inginiers at work, was
an Olivetti Programma 101 with IBM 80 columns magnetics cards. They explain me
but it was so complicated you know !
But do you know the algorythm to give all digit like in my 50g ?
May be a simple flowchart ?
Here is an HP-42S program that does what you want:

http://www.hpmuseum.org/cgi-sys/cgiwrap/...035#108692

Regards,

Gerson.
(04-11-2016 06:54 PM)Gerson W. Barbosa Wrote: [ -> ]Here is an HP-42S program that does what you want:

http://www.hpmuseum.org/cgi-sys/cgiwrap/...035#108692

Regards,

Gerson.

Hi,
Many thanks Gerson ! Do you know the program I've put in the other thread, in attachement, ?
(04-12-2016 06:53 AM)ggauny@live.fr Wrote: [ -> ]
(04-11-2016 06:54 PM)Gerson W. Barbosa Wrote: [ -> ]Here is an HP-42S program that does what you want:

http://www.hpmuseum.org/cgi-sys/cgiwrap/...035#108692

Regards,

Gerson.

Hi,
Many thanks Gerson ! Do you know the program I've put in the other thread, in attachement, ?

No, not yet, but thanks for posting.

1. Right click on the text in the internet address field then click on Select All, then click on Copy (or the equivalent in French in your browser);

+-------------------------------------------------+
| http://www.hpcalc.org/details.php?id=6011 |
+-------------------------------------------------+

2. Click on the "Insert hyperlink" icon (the small green and blue globe & chain links);

3. Place the cursor on the highlighted "http://" then right click, click on Paste and then click on OK;

4. Optionally, enter a description for the link, for instance, "Alistair Borowski's Fast Factorial program".

VoilĂ  ! :-)

Alistair Borowski's Fast Factorial program

Regards,

Gerson.
Hi,
Thanks for the treak.
A little bit complicated but I'm going to try for next sending !
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :