OFFSET
1,2
LINKS
MAPLE
ReverseNextPhi_n_elements_permutation(30); with(numtheory, phi); ReverseNextPhi_n_elements_permutation := proc(u) local m, a, n, k, i; a := []; k := 0; for n from 2 to u do m := k + phi(n); for i from 1 to phi(n) do a := [op(a), m]; m := m-1; k := k+1; od; od; RETURN(a); end;
MATHEMATICA
A[u_]:=Block[{m, a={}, n, k=0, i}, For[n=2, n<=u, n++, m=k + EulerPhi[n]; For[i=1, i<=EulerPhi[n], i++, AppendTo[a, m]; m=m - 1; k = k + 1]]; Return [a]]; A[30] (* Indranil Ghosh, May 23 2017, translated from MAPLE code *)
Reverse/@TakeList[Range[200], EulerPhi[Range[2, 20]]]//Flatten (* Harvey P. Dale, Oct 19 2022 *)
PROG
(Python)
from sympy import totient
def A(u):
a=[]
k=0
for n in range(2, u + 1):
m=k + totient(n)
for i in range(1, totient(n) + 1):
a+=[m, ]
m-=1
k+=1
return a
print(A(30)) # Indranil Ghosh, May 23 2017, translated from MAPLE code
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved