OFFSET
1,1
FORMULA
a(n) = a(n-1) + (2n-1)*prime(n) + n*(n-1). - Charlie Neder, Jun 21 2019
EXAMPLE
For n=1, the array is 2, and the sum is 2.
.
. 2 4
For n=2, the array is and the sum is 13.
. 4 3
.
. 2 4 7
For n=3, the array is 4 3 6 and the sum is 44.
7 6 5
PROG
(Excel, VBA)
Sub A308731()
n = 50
Cells(1, 1) = 2
p = 0
For i = 2 To n^2
isPrime = True
For j = 1 To p - 1
If i Mod Cells(j, j) = 0 Then
isPrime = False
Exit For
End If
Next j
If isPrime then
p = p + 1
Cells(p, p) = i
If p >= n Then
Exit For
End If
End If
Next i
For i = 2 To p
For j = 1 To i - 1
Cells(i, j) = Cells(i, i) + i - j
Cells(j, i) = Cells(i, j)
Next j
Next i
For i = 1 To n
Sum = 0
For k = 1 To i
For j = 1 To i
Sum = Sum + Cells(k, j)
Cells(i, n + 1) = Sum
Next j
Next k
Next i
End Sub
(PARI) M(i, j) = if (i>=j, prime(i)+i-j, M(j, i));
a(n) = sum(i=1, n, vecsum(vector(n, k, M(i, k)))); \\ Michel Marcus, Jun 21 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Ali Sada, Jun 20 2019
EXTENSIONS
Edited by Michel Marcus, Jun 21 2019
STATUS
approved