summaryrefslogtreecommitdiff
path: root/3808/CH2/EX2.2/Ex2_2.sce
blob: 809ed2d7fe2153dfedd3973ad193f074a747a73f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Chapter 02:Basic Structures: Sets, Functions, Sequences, Sums and Matrices

clc;
clear;

//To generate a sequence a_n=1/n
i=1.0 //floating point division
n=input("Enter the number of terms in the sequence:");
mprintf("\na_n=1/n")
mprintf("\nWhen n=%d   a_n is:",n)
for i=1:n //iteration till the number of terms specified by the user
a=1.0/i
mprintf( "\n1/%d,\t",i)
end
for i=1:n //iteration till the number of terms specified by the user
a=1.0/i
mprintf("\n%f,\t",a)
end