OFFSET
1,2
COMMENTS
A026741 generalized to give either a prime or the largest proper divisor of a nonprime.
Sometimes called "Conway's subprime function", although it surely predates John Conway. - N. J. A. Sloane, Sep 29 2017
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
MAPLE
A117818 := proc(n)
local a, d;
if isprime(n) or n =1 then
return n;
end if;
a := -1 ;
for d in numtheory[divisors](n) do
if d < n and d> a then
a := d ;
end if;
end do:
a ;
end proc:
seq(A117818(n), n=1..100) ; # R. J. Mathar, Apr 30 2024
MATHEMATICA
Table[If[PrimeQ[n], n, If[n == 1, 1, n/FactorInteger[n][[1, 1]]]], {n, 1, 76}]
Table[Which[n==1, 1, PrimeQ[n], 1, True, Divisors[n][[-2]]], {n, 80}] (* Harvey P. Dale, Feb 02 2022 *)
PROG
(Haskell)
a117818 n = if a010051 n == 1 then n else a032742 n
-- Reinhard Zumkeller, Jun 24 2013
(Python)
import sympy
def A117818(n):
if n == 1:
return 1
else:
_=sympy.ntheory.factor_.primefactors(n)
return _[-1]
print([A117818(n) for n in range(1, 100)])
# R. J. Mathar, May 24 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Roger L. Bagula, Apr 30 2006
EXTENSIONS
Edited by Stefan Steinerberger, Jul 22 2007
Extended by Charles R Greathouse IV, Jul 28 2010
STATUS
approved