Post Reply 
[VA] SRC #016 - Pi Day 2024 Special
03-17-2024, 01:45 AM
Post: #9
RE: [VA] SRC #016 - Pi Day 2024 Special
(03-16-2024 04:56 PM)C.Ret Wrote:  And since I have my HP-71B in hands, I modestly present you my attempt for the second apparence:

It is a (too long to edit) one-liner:
10 WHILE K<N @ K=K+1 @ C=C+(PGCD(CEIL(N*RND),CEIL(N*RND))=1) @ END WHILE @ DISP SQR(6*N/C);N @ N=10*N @ RUN


>DESTROY ALL
>N=1
[RUN]
2.44948974278  1
2.73861278753  10
3.03821810125  100
3.12347523777  1000
3.14502731861  10000
3.14037146511  100000


The appearance isn't efficient at all, perhaps my code is wrong !?
I may have use 1+IP(N*RND) instead of the CEIL functions.

As far I can see there’s nothing wrong with your code. Also, CEIL(N*RND) is more compact than 1+IP(N*RND).

Here’s another RPL program for the hp 50g using yours and Juan’s ideas:

« 0 DUP 5
FOR k k DUPDUP ALOG SWAP I→R SIGN + SWAP 1 + ALOG DUP UNROT
FOR n RAND OVER * CEIL RAND PICK3 * CEIL GCD 1 == ROT + SWAP
NEXT 6. * OVER / √ SWAP
NEXT DROP
»

1 RDZ TEVAL

->

2.92770021885
3.21633760451
3.18088727321
3.15074602744
3.14505324234
3.14173762276
:s: 851.5912


(time on the iHP48 emulator)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #016 - Pi Day 2024 Special - Gerson W. Barbosa - 03-17-2024 01:45 AM



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