login
A353051
Starting with x = n and repeatedly apply the map x -> x - sopfr(x) until 0, 1 or a prime is reached.
1
1, 2, 3, 0, 5, 1, 7, 2, 3, 3, 11, 5, 13, 5, 7, 2, 17, 3, 19, 11, 11, 3, 23, 7, 7, 11, 3, 17, 29, 11, 31, 3, 19, 7, 23, 11, 37, 17, 23, 29, 41, 11, 43, 29, 7, 11, 47, 37, 23, 17, 31, 23, 53, 43, 23, 43, 23, 3, 59, 37, 61, 29, 17, 23, 47, 17, 67, 47, 43, 43, 71, 37, 73
OFFSET
1,2
COMMENTS
Sopfr is the sum of prime factors with multiplicity (A001414) and the step subtracting that is A075255.
a(1) = 1. For n > 1, if n is prime, then a(n) = n. Otherwise, we subtract from n the sum of its prime factors with multiplicity and repeat until we arrive at 0, 1, or a prime, which is then a(n).
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
Sequence in context: A071321 A071322 A072594 * A272591 A339694 A074722
KEYWORD
nonn
AUTHOR
Tamas Sandor Nagy, Apr 20 2022
STATUS
approved