# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everybody I have had my hp prime for a few weeks now and I have trouble entering this program directly in the calculator. It says that there is a sintaxis problem. Can you help me fix it?Thank you.
This is the programm:
EXPORT PARAL(L1)
BEGIN
LOCAL T;
LOCAL I;
LOCAL N;
T:=0;
I:=0;
N:=SIZE(L1);

FOR I FROM 1 TO N DO
T:=T+1/L1(I);
END;

T:=1/T;
RETURN(T);
END;
Try replacing 'SIZE' with 'length'.
It says than the error is in line 4 and I don't understand why because I used the same sintaxis in line 3
The problem is the way you pass in the LIST (L1): Lists can't be used as inputs in the case.

Pre-define your list L1 then run this code:

Code:
``` EXPORT PARAL()  // Removed reference to L1 BEGIN LOCAL T; LOCAL I; LOCAL N; T:=0; I:=0; N:=SIZE(L1); FOR I FROM 1 TO N DO T:=T+1/L1(I); END; T:=1/T; RETURN(T); END;```
I would just replace SIZE with lenght as it will work with both lists and vectors.

Code:
``` EXPORT PARAL(L1) BEGIN LOCAL T; LOCAL I; LOCAL N; T:=0; I:=0; N:=length(L1); FOR I FROM 1 TO N DO T:=T+1/L1(I); END; T:=1/T; RETURN (T); END;```

Example:

Both PARAL([1 2 3]) and PARAL({1,2,3}) will return 6/11, which is equivalent to 0.545454....
Now it says there is a problem with T:=0;
Are you sure you have the latest version of the Prime software?

With version 6975 I have no errors with your program.
Here is what I got:
[attachment=1810] [attachment=1811]

Regarding the variable names in your program I would recommend not to use Global names for local variables as this can be confusing. Having L1 as your program parameter doesn't change the content of the L1 global variable but this is confusing as well as using T, I and N for local variables. I would use lower case names instead of upper case to show the difference.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :