Lesson 02
Lesson 02
2.1 Summation
sum(f(k),k=m..n)
O sum(r,r=1..n);
1 2 1 1
n C1 K nK (1)
2 2 2
O factor(%);
1
n n C1 (2)
2
O sum(k,k=0..n-1);
1 2 1
n K n (3)
2 2
O factor(%);
1
n n K1 (4)
2
O sum(k+1,k=0..n);
1 2 1 1
n C1 C nC (5)
2 2 2
O sum(1/k!,k=0..infinity);
e (6)
O sum(1/(k-1)!,k=1..infinity);
e (7)
O sum((-1)^(k+1)*(4/(2*k-1)),k=1..infinity);
p (8)
O sum(r^2,r=1..100);
338350 (9)
O add(i^2,i=1..5);
55 (10)
O L:=[seq(i,i=1..5)];
1, 2, 3, 4, 5 (11)
O add(i,i=L);
15 (12)
sigma(n)
O with(numtheory);
GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divisors, factorEQ, factorset, fermat, imagunit, (13)
index, integral_basis, invcfrac, invphi, iscyclotomic, issqrfree, jacobi, kronecker, l,
legendre, mcombine, mersenne, migcdex, minkowski, mipolys, mlog, mobius, mroot, msqrt,
nearestp, nthconver, nthdenom, nthnumer, nthpow, order, pdexpand, f, p, pprimroot,
primroot, quadres, rootsunity, safeprime, s, sq2factor, sum2sqr, t, thue
O divisors(20);
1, 2, 4, 5, 10, 20 (14)
O sigma(20);
42 (15)
O divisors(111);
1, 3, 37, 111 (16)
O sigma(111);
152 (17)
O divisors(2019);
1, 3, 673, 2019 (18)
O sigma(2019);
2696 (19)
EXERCISES
1)
O irem(sum(r!,r=1..100),2);
1 (20)
2)
a.
O sum(i,i=1..n);
1 2 1 1
n C1 K nK (21)
2 2 2
O factor(%);
1
n n C1 (22)
2
b.
O sum(i+(i-1),i=1..n);
2
n C1 K2 n K1 (23)
O factor(%);
2
n (24)
c.
O sum(i*(i+1),i=1..n);
1 1 1 3
K nK C n C1 (25)
3 3 3
O factor(%);
1
n n C2 n C1 (26)
3
d.
O sum(i*(i+2),i=1..n);
1 2 5 5 1 3
n C1 K nK C n C1 (27)
2 6 6 3
O factor(%);
1
n 2 n C7 n C1 (28)
6
e.
O sum(i*(i!),i=1..n);
n C1 ! K1 (29)
f.
O sum(1/(2^i),i=1..n);
n C1
1
K2 C1 (30)
2
O factor(%);
n C1
1
K2 C1 (31)
2
g.
O sum(i^3,i=1..n);
1 4 1 3 1 2
n C1 K n C1 C n C1 (32)
4 2 4
O factor(%);
1 2 2
n n C1 (33)
4