%I #15 Mar 30 2021 21:09:29
%S 0,31,211,961,2851,7471,15541,31471,55651,95821,152041,239791,351331,
%T 517831,723241,1007041,1352041,1821721,2359051,3082921,3904081,
%U 4956901,6151651,7677901,9334261,11445361,13746181,16566691,19644031,23432851,27408331,32333581
%N Number of distinct lines through the origin in 5-dimensional cube of side length n.
%C Equivalently, number of lattice points where the GCD of all coordinates = 1.
%F a(n) = A090030(5, n).
%F a(n) = (n+1)^5 - 1 - Sum_{j=2..n+1} a(floor(n/j)). - _Chai Wah Wu_, Mar 30 2021
%e a(2) = 211 because the 211 points with at least one coordinate=2 all make distinct lines and the remaining 31 points and the origin are on those lines.
%t aux[n_, k_] := If[k == 0, 0, (k + 1)^n - k^n - Sum[aux[n, Divisors[k][[i]]], {i, 1, Length[Divisors[k]] - 1}]];lines[n_, k_] := (k + 1)^n - Sum[Floor[k/i - 1]*aux[n, i], {i, 1, Floor[k/2]}] - 1;Table[lines[5, k], {k, 0, 40}]
%o (Python)
%o from functools import lru_cache
%o @lru_cache(maxsize=None)
%o def A090027(n):
%o if n == 0:
%o return 0
%o c, j = 1, 2
%o k1 = n//j
%o while k1 > 1:
%o j2 = n//k1 + 1
%o c += (j2-j)*A090027(k1)
%o j, k1 = j2, n//j2
%o return (n+1)**5-c+31*(j-n-1) # _Chai Wah Wu_, Mar 30 2021
%Y Cf. A000225, A001047, A060867, A090020, A090021, A090022, A090023, A090024 are for n dimensions with side length 1, 2, 3, 4, 5, 6, 7, 8, respectively. A049691, A090025, A090026, A090027, A090028, A090029 are this sequence for 2, 3, 4, 5, 6, 7 dimensions. A090030 is the table for n dimensions, side length k.
%K nonn
%O 0,2
%A _Joshua Zucker_, Nov 25 2003
|