cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A385084 Smallest integer value of Manhattan(v) + Euclidean(v) where v is a vector of n positive integers, and Manhattan(v) = Sum v[i] and Euclidean(v) = sqrt(Sum v[i]^2).

Original entry on oeis.org

2, 12, 8, 6, 12, 10, 14, 14, 12, 16, 20, 22, 18, 22, 26, 20, 24, 28, 26, 30, 30, 28, 36, 34, 30, 38, 36, 36, 42, 38, 42, 44, 40, 44, 46, 42, 48, 48, 54, 50, 50, 56, 52, 58, 58, 54, 60, 60, 56, 62, 66, 64, 64, 68, 66, 66, 70, 68, 74, 74, 70, 76, 76, 72, 78, 78, 80
Offset: 1

Views

Author

Charles L. Hohn, Jun 17 2025

Keywords

Comments

Manhattan and Euclidean are distance measures from the origin for v as coordinates of a point in n-dimensional space.
Integer Euclidean(v) requires that v is a Pythagorean n-tuple.
These distances are a walk from the origin by a positive integer number of unit steps in each of the n dimensions, and a return to the origin by a straight line which is also an integer number of unit steps.
When n is a square, a(n) = n + sqrt(n) from v all 1's.

Examples

			For n=2, v is the legs of a Pythagorean triangle and the smallest Manhattan + Euclidean is a(2) = 12 from v = {3,4}.
a(3) = 8 because 1 + 2 + 2 + sqrt(1^2 + 2^2 + 2^2) =  1 + 2 + 2 + 3 = 8.
a(4) = 6 because 1 + 1 + 1 + 1 + sqrt(1^2 + 1^2 + 1^2 + 1^2) = 1 + 1 + 1 + 1 + 2 = 6.
a(29) = 42: 3^2 + (4 * 2^2) + (24 * 1^2) = 7^2, and 6^2 + (28 * 1^2) = 8^2 (first term with multiple different examples).
		

Programs

  • PARI
    a(n)={my(r=oo); for(c=0, oo, if(n+sqrtint(n-1)+1+c>=r, return(r)); forpart(p=c, my(s=sum(i=1, #p, (p[i]+1)^2)+(n-#p)); if(issquare(s), r=min(r, n+c+sqrtint(s))), , n))}