OFFSET
1,2
COMMENTS
LINKS
Thomas Scheuerle, Scatter plot of terms 0 to 100000.
EXAMPLE
a(4) = 0 because 4 = 2*2, and 4 - (2 + 2) = 0.
a(6) = 1 because 6 = 2*3, and 6 - (2 + 3) = 1.
a(7) = 7 because 7 itself is a prime.
a(25) = 7 because 25 = 5*5, and 25 - (5 + 5) = 15, a composite number, so by repeating the process 15 = 3*5, and 15 - (3 + 5) = 7 which is a prime.
MATHEMATICA
a[n_] := NestWhile[# - Plus @@ Times @@@ FactorInteger[#] &, n, CompositeQ]; Array[a, 100] (* Amiram Eldar, Apr 20 2022 *)
PROG
(MATLAB)
function a = A353051(max_n)
for n = 1:max_n
m = n;
while ~isprime(m) && m > 2
m = m - sum(factor(m));
end
a(n) = m;
end
end % Thomas Scheuerle, Apr 20 2022
(PARI) a(n) = while(n>1&&!isprime(n), my(f=factor(n)); n -= f[, 1]~*f[, 2]); n; \\ Kevin Ryde, Apr 20 2022
(Python)
from sympy import factorint
def A353051(n):
while n > 1 and len(f:=factorint(n, multiple=True)) > 1:
n -= sum(f)
return n # Chai Wah Wu, May 19 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Tamas Sandor Nagy, Apr 20 2022
STATUS
approved