login
A153023
If n is 1 or prime then a(n) = n. Otherwise, start with n and iterate the map k -> A048050(k) until we reach a prime p; then a(n) = p. If we never reach a prime, a(n) = -1. A048050 gives the sum of proper divisors of k, excluding both 1 and n from the sum.
2
1, 2, 3, 2, 5, 5, 7, 5, 3, 7, 11, 5, 13, 3, 5, 3, 17, 7, 19, 7, 7, 13, 23, 5, 5, 5, 5, 5, 29, 41, 31, 41, 3, 19, 5, 7, 37, 7, 3, 7, 41, 53, 43, 3, 41, 5, 47, -1, 7, 53, 7, 41, 53, 7, 3, 7, 13, 31, 59, 107, 61, 3, 7, 3, 7, 7, 67, 13, 5, 73, 71, 7, 73, 3, -1, 7, 7, 89, 79, 41, 3, 43, 83, 139, 13
OFFSET
1,2
LINKS
EXAMPLE
a(18) -> {2,3,6,9} -> 20 -> {2,4,5,10} -> 21 -> {3,7} -> 10 -> {2,5} -> 7 = 7.
MAPLE
f := proc(n) L := {} ; a := n ; while not isprime(a) do a := A048050(a) ; if a in L then RETURN(-1) ; fi; L := L union {a} ; od; a ; end:
A048050 := proc(n) numtheory[sigma](n)-n-1 ; end:
A153023 := proc(n) if n =1 then 1; elif isprime(n) then n; else f(n) ; fi; end: # R. J. Mathar, Dec 19 2008
MATHEMATICA
Table[If[! CompositeQ[n], n, NestWhile[DivisorSigma[1, #] - (# + 1) &, n, Nor[PrimeQ@ #, # == 0] &, 1, 100] /. k_ /; CompositeQ@ k -> -1], {n, 85}] (* Michael De Vlieger, Nov 03 2017 *)
PROG
(Scheme)
(define (A153023 n) (let loop ((n n) (visited (list n))) (let ((next (A048050 n))) (cond ((or (= 1 n) (= 1 (A010051 n))) n) ((member next visited) -1) (else (loop next (cons next visited)))))))
(define (A048050 n) (if (= 1 n) 0 (- (A001065 n) 1)))
(define (A001065 n) (- (A000203 n) n)) ;; For an implementation of A000203, see under that entry.
;; Antti Karttunen, Nov 03 2017
CROSSREFS
KEYWORD
sign
AUTHOR
Andrew Carter (acarter09(AT)newarka.edu), Dec 16 2008
EXTENSIONS
Extended by R. J. Mathar, Dec 19 2008
Description clarified by Antti Karttunen, Nov 03 2017
STATUS
approved