For the purposes of the assignment, I need these values in a table. We have so far only used for/while loops to check the deficiency or abundance of certain types of numbers. I initially tried using a for loop and AppendTo at my instructor's suggestion, but I couldn't get it to work.
I briefly dabbled with sow and reap, but I had no idea where to start with it. Then I found the TakeWhile function and thought that would work. But it didn't seem to know what to do with DivisorSum in the criteria. Is there a way to make TakeWhile[list,#
Here's what I've tried, sorry it's a such a mess.
n = 100;
(*While[x\[LessEqual]n,Print[StringForm["Divisors of `` = ``; sum of \
divisors = `` `` `` (``)" \
,x,Most[Divisors[x]],ds=DivisorSum[(x),#&,#<x&],Piecewise[{{">",ds>x},\
{"<",ds<x},{"=",ds=x}}],x,Piecewise[{{"abundant",ds>x},{"deficient",\
ds<x},{"perfect",ds=x}}]]];x=x+1;i=x]*)
def = {}
(*Array[def,n]*)
\
(*AppendTo[def,For[i=1,i\[LessEqual]n,i++,Print[{i,DivisorSum[i,#&,#<\
i&]}]]]*)
\
(*For[i=1,i\[LessEqual]n,i++,Print[{i,DivisorSum[i,#&,#<i&]}]]*)
\
(*For[i=1,i\[LessEqual]n,i++,Print[StringForm["Sum of proper divisors \
for `` = `` this is `` `` \
(``)",i,ds=DivisorSum[i,#&,#<i&],Piecewise[{{">",ds>i},{"<",ds<i},{"=\
",ds=i}}],i,Piecewise[{{"abundant",ds>i},{"deficient",ds<i},{\
"perfect",ds=i}}]]]]*)
div =
For[i = 1, i <= n, i++, Print[{i, a = DivisorSum[i, # &, # < i &]}]]
TakeWhile[{div}, # < a]
num = Table[i + 1, {i, 0, 99}]
divtb = Table[DivisorSum[i, # &, # < i &], {i, n}]
TakeWhile[num, # < DivisorSum[#, # &, # < i &]]
Any and all suggestions appreciated. Thanks.