Sharedseq.sagewsOpen in CoCalc
Author: Matt Thomas
Views : 2
%typeset_mode True
a(n)=1/n
for i in [1..10]: a(i)
1\displaystyle 1
12\displaystyle \frac{1}{2}
13\displaystyle \frac{1}{3}
14\displaystyle \frac{1}{4}
15\displaystyle \frac{1}{5}
16\displaystyle \frac{1}{6}
17\displaystyle \frac{1}{7}
18\displaystyle \frac{1}{8}
19\displaystyle \frac{1}{9}
110\displaystyle \frac{1}{10}
[a(i) for i in [1..10]]
[1\displaystyle 1, 12\displaystyle \frac{1}{2}, 13\displaystyle \frac{1}{3}, 14\displaystyle \frac{1}{4}, 15\displaystyle \frac{1}{5}, 16\displaystyle \frac{1}{6}, 17\displaystyle \frac{1}{7}, 18\displaystyle \frac{1}{8}, 19\displaystyle \frac{1}{9}, 110\displaystyle \frac{1}{10}]
L = [a(i) for i in [1..10]]
L
[1\displaystyle 1, 12\displaystyle \frac{1}{2}, 13\displaystyle \frac{1}{3}, 14\displaystyle \frac{1}{4}, 15\displaystyle \frac{1}{5}, 16\displaystyle \frac{1}{6}, 17\displaystyle \frac{1}{7}, 18\displaystyle \frac{1}{8}, 19\displaystyle \frac{1}{9}, 110\displaystyle \frac{1}{10}]
L[1]
12\displaystyle \frac{1}{2}
points([(a(i),0) for i in [1..10]], pointsize=50)
def a(n): if n==1: return 1 else: return (n*a(n-1))
a(5)
120\displaystyle 120
for i in [1..5]: a(i)
1\displaystyle 1
2\displaystyle 2
6\displaystyle 6
24\displaystyle 24
120\displaystyle 120
list_plot([a(i) for i in [1..5]], color='green', pointsize=50)
a(n)=1/n list_plot([a(i) for i in [1..10]])
list_plot([s(n) for n in [1..10]])
N(s(100))
5.18737751763962\displaystyle 5.18737751763962
L = [s(n) for n in [1..10]]
L
[1\displaystyle 1, 32\displaystyle \frac{3}{2}, 116\displaystyle \frac{11}{6}, 2512\displaystyle \frac{25}{12}, 13760\displaystyle \frac{137}{60}, 4920\displaystyle \frac{49}{20}, 363140\displaystyle \frac{363}{140}, 761280\displaystyle \frac{761}{280}, 71292520\displaystyle \frac{7129}{2520}, 73812520\displaystyle \frac{7381}{2520}]
L[1]
32\displaystyle \frac{3}{2}
L[0]
1\displaystyle 1