login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Start subtracting from n its divisors beginning from 1 until one reaches a number smaller than the last divisor subtracted or reaches the last nontrivial divisor < n. Define this to be the perfect deficiency of n. Then a(n) = perfect deficiency of n.
11

%I #28 Apr 01 2024 02:33:31

%S 0,1,2,1,4,0,6,1,5,2,10,2,12,4,6,1,16,6,18,8,10,8,22,0,19,10,14,0,28,

%T 3,30,1,18,14,22,11,36,16,22,10,40,9,42,4,12,20,46,12,41,7,30,6,52,15,

%U 38,20,34,26,58,2,60,28,22,1,46,21,66,10,42,31,70,9,72,34,26,12,58,27,78

%N Start subtracting from n its divisors beginning from 1 until one reaches a number smaller than the last divisor subtracted or reaches the last nontrivial divisor < n. Define this to be the perfect deficiency of n. Then a(n) = perfect deficiency of n.

%C If n is a perfect number then a(n) = 0. But if a(n) = 0, n needs not be perfect, e.g., a(24) = 0, but 24 is not a perfect number. See A064510.

%H Nathaniel Johnston, <a href="/A109883/b109883.txt">Table of n, a(n) for n = 1..10000</a>

%F a(1) = 0, a(2^n) = 1.

%F a(p) = p-1, a(p^n) = (p^(n+1) - 2*p^n + 1)/(p-1), if p is a prime.

%F a(n) = n - A117552(n). - _Ridouane Oudra_, Jan 25 2024

%e a(14) = 4: 14-1 = 13, 13-2 = 11, 11-7 = 4.

%e a(6) = 0: 6-1 = 5, 5-2 = 3, 3-3 = 0. 6 is a perfect number.

%e a(35) = 22: 35-1 = 34, 34-5 = 29, 29-7 = 22.

%p A109883:=proc(n)local d,j,k,m:if(n=1)then return 0:fi:j:=1:m:=n:d:=divisors(n);k:=nops(d):for j from 1 to k do m:=m-d[j]:if(m<d[j+1])then return m:fi:od:end: # _Nathaniel Johnston_, Apr 15 2011

%t subtract = If[ #1 < #2, Throw[ #1], #1 - #2]&;

%t a[n_] := Catch @ Fold[subtract, n, Divisors @ n]

%t Table[ a[n], {n, 80}] (* Bobby R. Treat (DrBob(AT)bigfoot.com), Jul 14 2005 *)

%o (PARI) a(n) = {my(r = n); fordiv(n, d, if (r < d, return (r)); r -= d;); 0;} \\ _Michel Marcus_, Dec 28 2018

%o (Python)

%o from sympy import divisors

%o def A109883(n):

%o if n == 1: return 0

%o s = n

%o for d in divisors(n)[:-1]:

%o if s < d: break

%o s -= d

%o return s

%o print([A109883(n) for n in range(1, 80)]) # _Michael S. Branicky_, Mar 31 2024

%Y Cf. A064510, A109884, A109886, A117552.

%K easy,nonn

%O 1,3

%A _Amarnath Murthy_, Jul 11 2005

%E More terms from _Jason Earls_ and _Robert G. Wilson v_, Jul 12 2005