Post Reply 
Programming Exercise (HP-15C, 15C LE - and others)
03-26-2014, 07:01 PM (This post was last modified: 03-26-2014 07:02 PM by Gerson W. Barbosa.)
Post: #41
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-26-2014 06:20 PM)churichuro Wrote:  version for HP PRIME:

Code:

EXPORT TEST2()
BEGIN
  LOCAL suma,n;

  suma:= 0;
  FOR n FROM 10000 DOWNTO 1 DO
    suma:= suma + (1/n)*(-1)^(n+1);
  END;
  MSGBOX("Suma="+suma);
END;

result in about 1 sec !
Suma=.693097183059


Isn't "FOR n FROM 10000 DOWNTO 2 STEP -2 DO" a valid syntax in your UBASIC? If so, then the following would be worth trying. ¡Gracias!


Code:

1 T=TIME @ S=0 @ FOR N=10000 TO 2 STEP -2 @ S=S+1/(N-1)-1/N @ NEXT N @ DISP S;TIME-T
.69309718306 247.27

4 minutes and 7 seconds! (HP-71B)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 03-26-2014 07:01 PM



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