I think this is similar to your other replies, but it might still be of
interest:
1 p: ". }.^:(i.@<:@#) @: ('x',~":) 357686312646216567629137x
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
With your smaller example:
ltruncall =: }.^:(i.@<:@#) @: ('x',~":)
ltruncall 6391373x
6391373x
391373x
91373x
1373x
373x
73x
3x
(1 p: ".) ltruncall 6391373x
1 1 1 1 1 1 1
Mike
On 19/11/2022 21:51, Richard Donovan wrote:
Hi
I am doing experiments with large primes, in particular looking at primes that
remain primes when n digits are truncated from the left. For example
6391373 391373 91373 1373 373 73 3 remains prime at each step.
The largest of these in base 10 is 357686312646216567629137.
I wrote the following code in preparation for further investigation but I find
that the 24 digit number above is not handled as I wish it to be, as you will
see below.
What have I missed?
Thanks
digits
"."0@":
ltrunc
3 : 0"0 0 0
n=: ": 0, }. digits y
x: ". n-. ' '
)
NB. Works fine with 7 digit number...
ltrunc^:a: 6391373
6391373 391373 91373 1373 373 73 3 0
NB. But I can’t get it working for a 24 digit number!
ltrunc 357686312646216567629137
0 0 5 7 6 8 6 0 2 3
ltrunc 357686312646216567629137x
57686312646216568012800
ltrunc x:357686312646216567629137x
57686312646216568012800
Is there a way around the limit?
----------------------------------------------------------------------
For information about J forums seehttp://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm