All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Divisors' sum = square (Posted on 2019-05-27) Difficulty: 2 of 5
The number 22 divisors are 1, 2, 11, 22, which add up to 36, a square.
There are 4 more numbers like that below 100.

List them.

See The Solution Submitted by Ady TZIDON    
Rating: 3.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 9
Actually there are five more such numbers, including 3. The divisors of 3 are 1 and 3 which add up to 2^2; 3 is the only one that's prime.

The below list shows 

on the first line, the number and the sum of its divisors
on the second line, the list of divisors

3 4
 1 3

22 36
 1 11 2 22

66 144
 1 11 3 33 2 22 6 66

70 144
 1 7 5 35 2 14 10 70

81 121
 1 3 9 27 81

94 144
 1 47 2 94

DefDbl A-Z
Dim crlf$, fct(20, 1), sdiv, f, dvsr, ndiv, divlist(100)


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For n = 2 To 100
   sdiv = 0: dvsr = 1
   ndiv = 0
   f = factor(n)
   addthem 1
   sr = Int(Sqr(sdiv) + 0.5)
   If sr * sr = sdiv Then
      Text1.Text = Text1.Text & n & Str(sdiv) & crlf
      For i = 1 To ndiv
        Text1.Text = Text1.Text & Str(divlist(i))
      Next
      Text1.Text = Text1.Text & crlf
   End If
   DoEvents
 Next
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Sub addthem(wh)
  For howmany = 0 To fct(wh, 1)
    savedvsr = dvsr
    dvsr = Int(dvsr * fct(wh, 0) ^ howmany + 0.5)
    
    If wh = f Then
      sdiv = sdiv + dvsr
      ndiv = ndiv + 1
      divlist(ndiv) = dvsr
    Else
      addthem wh + 1
    End If
    
    dvsr = savedvsr
  Next
End Sub


Function factor(num)
 diffCt = 0: good = 1
 n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
 If limit <> Int(limit) Then limit = Int(limit + 1)
 dv = 2: GoSub DivideIt
 dv = 3: GoSub DivideIt
 dv = 5: GoSub DivideIt
 dv = 7
 Do Until dv > limit
   GoSub DivideIt: dv = dv + 4 '11
   GoSub DivideIt: dv = dv + 2 '13
   GoSub DivideIt: dv = dv + 4 '17
   GoSub DivideIt: dv = dv + 2 '19
   GoSub DivideIt: dv = dv + 4 '23
   GoSub DivideIt: dv = dv + 6 '29
   GoSub DivideIt: dv = dv + 2 '31
   GoSub DivideIt: dv = dv + 6 '37
   If INKEY$ = Chr$(27) Then s$ = Chr$(27): Exit Function
 Loop
 If n > 1 Then diffCt = diffCt + 1: fct(diffCt, 0) = n: fct(diffCt, 1) = 1
 factor = diffCt
 Exit Function

DivideIt:
 cnt = 0
 Do
  q = Int(n / dv)
  If q * dv = n And n > 0 Then
    n = q: cnt = cnt + 1: If n > 0 Then limit = Sqr(n) Else limit = 0
    If limit <> Int(limit) Then limit = Int(limit + 1)
   Else
    Exit Do
  End If
 Loop
 If cnt > 0 Then
   diffCt = diffCt + 1
   fct(diffCt, 0) = dv
   fct(diffCt, 1) = cnt
 End If
 Return
End Function


  Posted by Charlie on 2019-05-27 15:54:32
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information