Group Abstract Group Abstract

Message Boards Message Boards

0
|
3K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Is there a way to show the factors of a Perfect Number expressed as a sum rather than a product

Posted 1 year ago

Hi,

Normally, FactorInteger[] function outputs all the prime factors of a number as a list composed of the factors and their exponents, but I would like to see the output expressed as the sum of all the proper factors (all factors less than the value). Here are 3 examples that should help illustrate what I'm looking for:

  1. FactorInteger[28] output would show {{2, 2}, {7, 1}} but I would like to see it expressed as:

     28 = 1 + 2 + 4 + 7 + 14
    
  2. FactorInteger[496] outuput would show {{2, 4}, {31, 1}}, but I would like to see it expressed as:

    496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248
    
  3. FactorInteger[8128] output would show {{2,6}, {127, 1}}, but I would like to see it expressed as:

    8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064
    

I also just came across the Divisors[] function that creates a list of all possible divisors of a given value, which is sorta close, but would really like to see the values expressed as a sum rather than a list of values. I also found the Drop[] function that would remove the last element so that it's easy to see the entire list of proper divisors, but really would like to express it as a sum rather than the list. E.G.

In[1]:= Drop[Divisors[8128], -1]

Out[1]= {1, 2, 4, 8, 16, 32, 64, 127, 254, 508, 1016, 2032, 4064}

So, how would I transform this to something like

8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064

Any suggestions?? Thanks very much...

-bob

POSTED BY: Bob Freeman
4 Replies
POSTED BY: Michael Rogers
Posted 1 year ago

Here's an approach:

PerfectSumForm[n_?PerfectNumberQ] := Inactive[Plus] @@ Most[Divisors[n]];

PerfectSumForm[8128]
(* This will display as
   1+2+4+8+16+32+64+127+254+508+1016+2032+4064
   You can allow the sum to execute with Activate*)

PerfectSumForm[8128] // Activate
(* 8128 *)
POSTED BY: Eric Rimbey
Posted 1 year ago

If all you want to do is to see the result then

Plus@@Map[HoldForm,Drop[Divisors[8128], -1]]

returns this

1+2+4+8+16+32+64+127+254+508+1016+2032+4064

But the appearance of that is different from what is behind the scene. You can use ReleaseHold to turn that into something you can then use in another calculation, but the sum will be immediately calculated when you do that

POSTED BY: Bill Nelson

Just what the doctor ordered!!! Thanks very much.

POSTED BY: Bob Freeman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard