OFFSET
1,2
FORMULA
EXAMPLE
For n = 10, the divisors of n are {1,2,5,10}. The largest nontrivial divisor is 5, so 10 * 10 - 5 = 95.
MATHEMATICA
Table[
Module[{divisors, largestNonTrivialDivisor},
divisors = Divisors[n];
largestNonTrivialDivisor = If[Length[divisors] > 2, divisors[[-2]], 0];
n^2 - largestNonTrivialDivisor
],
{n, 1, 20}
]
PROG
(Python)
def factors(n):
return sorted([i for i in range(2, n - 1) if n % i == 0])
def main():
for i in range(1, 20):
fs = factors(i)
if len(fs) == 0:
l = 0
else:
l = fs[-1]
print(i*i - l)
if __name__ == "__main__":
main()
CROSSREFS
KEYWORD
nonn
AUTHOR
Stephen Pearson, Jul 04 2024
STATUS
approved