divisors(n)
that returns the list of positive divisors of an integer $n$ arranged in ascending order.
perfect(n)
that returns the list of all perfect numbers between 1 and $n$.
We consider a simple statistical series $\{ \; (x_i\,,\,n_i)\;\mathrm{with}\; 1\leq i\leq p\}$. Its average $m$ and its variance $V$ are defined by :
$ m=\frac{1}{N}\sum_{i=0}^{p} n_i\,x_i \qquad\mathrm{and}\qquad V=\frac{1}{N}\sum_{i=0}^{p}n_i(x_i-m)^2$
$N$ refers to the total number of people in the study population.
xi
and ni
. (xi
being the list of observed values of the characteristic and ni
those of the associated numbers)
moy(x,n)
.
var(x,n)
.
It is decided to code a secret message as follows:
Write a Python function that takes as a parameter a string written in lowercase and without accent, and returns the string encoded by the refined encryption described above.
Douglas Hofstadter left his name in the following sequence, in his bookGodel, Escher, Bach:
1 3 7 12 18 26 35 45 56 69 83 98 114 131
To understand how it works, let's write below the sequence of the first differences (these are the quantities that separate a term from its neighbour):
S : 1 3 7 12 18 26 35 45 56 69 83 98 114 131 d : 2 4 5 6 8 9 10 11 13 14 15 16 17
...the numbers that do not appear in the first sequence are in the second, and vice versa. This is the very definition of this sequence: it is constructed by adding to the last written number the smallest integer not present in S or d.
Build the Hofstadter suite. We will do a function that associates $n$ with the $n$-th term of this suite.
The Euler indicator function $\phi(n)$ is equal to the number of integers between 0 and $n-1$ that are coprime with $n$, agreeing that
1. Make a function that builds the Pascal's triangle up to his $n$-th line. It will return a list of lists.
2. Make a function that receives this list of lists as an argument, and which returns a triangle representation:
1 | ||||||
1 | 1 | |||||
1 | 2 | 1 | ||||
1 | 3 | 3 | 1 | |||
1 | 4 | 6 | 4 | 1 | ||
1 | 5 | 10 | 10 | 5 | 1 | |
1 | 6 | 15 | 20 | 15 | 6 | 1 |
3. Use this function to experimentally verify that the sum of the terms of the $n$-th line is equal to $2^n$.