## Show all digits of a huge integer

General discussion about calculators, SwissMicros or otherwise
rudi
Posts: 275
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

### Show all digits of a huge integer

On my C43, I have a large integer with ca 288 digits and I would like to see all digits.
However, when executing the command SHIFT SHOW, "only" 270 digits are shown, the groups of three digits ends with a 0...

Is it possible to see all in another way? Or does it mean that all the remaining digits are 0?
/Rudi

DM-42 as C43 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)
Jaymos
Posts: 989
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

### Re: Show all digits of a huge integer

rudi wrote:
Tue Jan 24, 2023 11:53 am
On my C43, I have a large integer with ca 288 digits and I would like to see all digits.
However, when executing the command SHIFT SHOW, "only" 270 digits are shown, the groups of three digits ends with a 0...

Is it possible to see all in another way? Or does it mean that all the remaining digits are 0?
The logic tells it to stop listing digits because it is almost full. The ellipsis indicates there are more digits which will not be displayed. It does not mean it is zeroes and can be any number of any digits.

It actually supports 294 digits in SHOW before the ellipsis is shown. We could clear the softmenu to display more digits. That would not be hard, but it does not solve the problem because there could be around 1000 digits, so the work needed to display 3 more lines does not really help.

Print to file using g[EXIT] to get the full number on file.
Jaco Mostert
Elec Eng, South Africa
C43 on DM42 03818, 06199, WP43 pilot 0015. In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; previous FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42, WP31S/34S, HCalc.
rudi
Posts: 275
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

### Re: Show all digits of a huge integer

Thanks Jaymos - didn't think of printing and then getting out the file.
Would love to be able to browse all digits though

Guess that I could write a small program for that - I'll try having a look at that.
/Rudi

DM-42 as C43 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)
pauli
Posts: 143
Joined: Tue May 02, 2017 10:11 am
Location: Australia

### Re: Show all digits of a huge integer

Sounds like a job for a short keystroke program. Break the number up in, say, twenty digit lumps and display or store in registers.
Jaymos
Posts: 989
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

### Re: Show all digits of a huge integer

pauli wrote:
Wed Jan 25, 2023 11:54 pm
Sounds like a job for a short keystroke program. Break the number up in, say, twenty digit lumps and display or store in registers.
Why don't we have a challenge?

Let's see who comes up with the shortest program to be able to view all digits of 2^2234.

Post the programs here. Multiple solutions from people are allowed, i.e. you may try again if someone beat you!

2^2234 must be in X before the program is started. 0 in all other stack registers. Default C43 flag and settings status assumed.

J
Jaco Mostert
Elec Eng, South Africa
C43 on DM42 03818, 06199, WP43 pilot 0015. In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; previous FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42, WP31S/34S, HCalc.
rudi
Posts: 275
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

### Re: Show all digits of a huge integer

What a great challenge, I'm in....
Why settle with $$2^{2234}$$, why not push it to $$2^{3326}$$ - well, any large number in the x register
/Rudi

DM-42 as C43 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)
Jaymos
Posts: 989
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

### Re: Show all digits of a huge integer

rudi wrote:
Thu Jan 26, 2023 11:33 am
What a great challenge, I'm in....
Why settle with $$2^{2234}$$, why not push it to $$2^{3326}$$ - well, any large number in the x register
Any large number must work, but the contest benchmark is for the largest one that produces 1000 digits, and I copied incorrectly from my screen!

2 ^ 3321 is the one which produces 5.2555 x 10^999. I don't know where I got 2 ^ 2234. Haha - yes I seemed to remember a pattern and did that wrong!

So 2^3321 it is.
Jaco Mostert
Elec Eng, South Africa
C43 on DM42 03818, 06199, WP43 pilot 0015. In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; previous FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42, WP31S/34S, HCalc.
BINUBALL
Posts: 31
Joined: Fri Jan 28, 2022 3:48 am
Location: South Korea

### Re: Show all digits of a huge integer

A straightforward solution. Dirty program... but eventually it works!

82 bytes / 35 steps

Code: Select all

LBL 'BREAK'
STO 00
LOG
IP
1
+
STO I
18
/
ceil
1000
/
1
+
STO J
LBL 00
RCL 00
RCL I
18
/
ceil
RCL J
IP
-
18
*
10^x
IDIV
18
10^x
MOD
STO→J
ISG J
GTO 00
END

It breaks down integer into 18 digits lumps and store it from R01.
2 3321 ^ R/S
=====>
5 255 518 873 in R01
824 416 903 687 982 113 in R02
...
23 697 137 731 633 152 in R56 (notice 0 is omitted)

EDIT) Found one problem with this: like large factorial, if you have many, many 0s at the end, we cannot distinguish where the integer finishes.
S.Korean / HP-50G | fx-570EX | fx-570CW | HP-200LX
Jaymos
Posts: 989
Joined: Sun Nov 04, 2018 7:03 pm
Location: Cape Town

### Re: Show all digits of a huge integer

My second try after independently seeing the zeroes issue: 105 bytes, 38 steps.

See register 23 - the problem of the leading zeroes would have been there.

Code: Select all

01 LBL ‘SPLIT’
02 34
03 10^X
04 STO 00
05 DROP
06 2
07 STO 01
08 DROP
09 LBL ‘LL’
10 ENTER
11 RCL 00
12 MOD
13 XEQ ‘->SS’
14 INC 01
15 -
16 RCL 00
17 IDIV
18 X ≠ ? 0.
19 GTO ‘LL’
20 𝑎 ‘END REG ‘
21 RCL 01
22 +
23 STO ->01
24 RTN
25 LBL ‘->SS’
26 ENTER
27 RCL 00
28 +                //Add 10^34 to preserve the zeroes
29 𝑎 ‘ ‘
30 +                //Add a space to convert to string
31 1
32 𝑎SL Y
33 𝑎SR Y
34 DROP
35 STO ->01
36 DROP
37 RTN
38.END.


To view it, you have to press g[REGS] 02, to make the register browser start at 2. The register after the last one will contain the end pointer and the X register ends with the same end pointer. I actually think there is no reason that we should not have REGS programmable. I think we should change that.
Screenshot 2023-01-26 at 19.54.40.jpg (192.25 KiB) Viewed 169 times
Last edited by Jaymos on Thu Jan 26, 2023 7:35 pm, edited 1 time in total.
Jaco Mostert
Elec Eng, South Africa
C43 on DM42 03818, 06199, WP43 pilot 0015. In box: HP42S, HP32Sii, WP34S&C, HP28C, HP35s, EL-506P, EL-W506, PB700; previous FX702P, 11C, HP67 & HP85; iOS: 42s Byron, Free42, WP31S/34S, HCalc.
rudi
Posts: 275
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

### Re: Show all digits of a huge integer

Nice one Jaymos.
First, I wanted to make a matrix with a 10 column row for each group of 10 digits, and use the matrix viewer, but found out, that there’s not enough RAM to make a 10x100 matrix.
Then I wanted to simply make a long string and use that to store all digits, but strings can not be 1000 chars long.
I have another idea, hope I get the time to implement it, but right now, there’s something else taking my attention, clear skies and C/2022 E3 (ZTF)
/Rudi

DM-42 as C43 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV, ex HP-75C, ex HP-48G + a lot, really lot of a accessories)