Maple 13. How to find sum of entiries of array via summation operator?

Mar 2010
20
6
I understand i can use loop (like "for..." or something else ) but i want do my program text more readable.
I declare array:
Code:
 A:=Array(1..5,[1,2,3,4,5])
It is OK.Then i trying to get sum of entries of array
Code:
S:=sum(A[i],i=1..5)
This yields error "Error,bad index into Array"
How can i fix it?
 

Jester

MHF Helper
Dec 2008
2,470
1,255
Conway AR
I understand i can use loop (like "for..." or something else ) but i want do my program text more readable.
I declare array:
Code:
 A:=Array(1..5,[1,2,3,4,5])
It is OK.Then i trying to get sum of entries of array
Code:
S:=sum(A[i],i=1..5)
This yields error "Error,bad index into Array"
How can i fix it?
Not sure why sum doesn't work but add does.
 
  • Like
Reactions: ICanFly