Print
Published on by

...And the same method for the HP Prime!

I have now noticed that my practice programming in any other language than RPN is lost. The Prime has a myriad of loop types, and I was lost trying to find the one that would suit better to this small program to calculate pi through Pythagoras Theorem for the Prime. Also I was not able to find the right means to stop the program for as long as needed, without resorting to ugly methods. But well, the program does what it intends to do, while showing all the values at each iteration.

EXPORT Pitagoras(D)

BEGIN

LOCAL LADO, POLY, C, R;

R:=D/2;

LADO:=R*sqrt(2);

POLY:=4;

C:=LADO*POLY;

FOR I FROM 2 TO 25 DO

PRINT(C);

WAIT(2);

POLY:=POLY*2;

LADO:=sqrt((LADO/2)^2+(R-sqrt(R^2-(LADO/2)^2))^2);

C:=LADO*POLY;

END;

PRINT(C);

END;

I'm sure you can make it much better - can you help me?

Comments: 0
More about: HP prime, pi, pythagoras

Only registered users may post comments.
Sign in and post comment Register now