Texas Instruments TITANIUM TI-89 User Manual
Page 640
Programming
640
Example 4
Example 4
Example 4
Example 4
This example uses built-in functions to calculate the result without using a loop.
Ê
Prompts for input on Program I/O.
Ë
Calculates sum.
Ì
Displays output on Program I/O screen.
Note:
Because
Input
returns
n
as a number, you do not need to use
expr
to convert
n
.
К
Л
М
:prog4()
:Prgm
:Input "Enter an integer",n
:sum(seq(i,i,1,n))
!
temp
:Disp temp
:EndPrgm
Function
Used in this example to:
seq
Generate the sequence of integers from 1 to n.
sum
Sum the integers in the list generated by seq.
seq(expression
,
var
,
low
,
high
[,
step
]
)
Ê
expression used to generate the sequence
Ë
variable that will be incremented
Ì
initial and final values of
var
Í
increment for var ; if omitted, uses 1
К
Л
М М
Н