Jump to content
Science Forums

Recommended Posts

  • 10 months later...
Posted

Sorry T, With numbers as large as a billion, I'm afraid it's taking my inefficient, uncompiled program an average of .05 seconds per number. At that rate, it would be many thousands of days before happy results :rolleyes:

 

I'll see if I can trim the fat when I have more time.

 

~modest

Posted

errrr... :friday:

 

No luck - I'm only able to check around 30 to 35 per second with numbers as large as a billion. I'll leave it running on a dedicated (but slightly slower) system that I hardly use, but I don't expect it will find anything any time soon.

 

I'm embarrassed to show this code because I am not a coder by any stretch of anybodies imagination, but maybe somebody who is will improve it or be able to point out where its dragging its feet :)

 

It's in PERL, and sorry, I didn't add comments,

 

use Term::ReadKey;

$startValue="$ARGV[0]";                                            
$endValue="$ARGV[1]";                                              
ReadMode 4;

for ($n = $startValue; ($n < $endValue) && (not defined ($key = ReadKey(-1))); ++$n){                        
 $divisorSum = 1;
 for ($checkFactor = 2; $checkFactor < sqrt($n); ++$checkFactor){   
   if ((int($n/$checkFactor))==($n/$checkFactor)){
     $divisorSum += ($n/$checkFactor)+$checkFactor;
   } 
 }
 if (int(sqrt($n))==sqrt($n)){                                     
     $divisorSum += sqrt($n);
 }
 if ($divisorSum==$n+12){                                                   
   if (int($n/6) == $n/6){                                        
     $checkPrime = $n/6;                                            
     $prime = 1;
     for ($i = 2; $i < (sqrt($checkPrime)+1) && $prime; ++$i){
       if (int($checkPrime/$i)==$checkPrime/$i){                    
         $prime = 0;
         print "number ",$n," is abundant by 12, with factors 6 & ",$checkPrime, " which is not prime n";
       }          
     }
   }
   if (int($n/6) != $n/6){                                          
   print "number ",$n," is abundant by 12 and not divisible by 6 n"; 
   }
 }
}

if ($key) {print "The program was terminated at n = ", $n;}
else {print "Done checking ",$startValue," - ",$endValue;} 
ReadMode 0; 

~modest

Posted
So; to the numbers! As I recall, Big Dog found 8,589,082,624 using his self-written Numberator software. That software is attached in several versions to some posts in this thread. :wave2: When B Dog reported the find, I then used the software to display & recover the factors. I seem to further recall the effort took him a couple weeks? :) It was a dedicated lengthy effort in any regard. :friday:

 

I've found an attachment in #166, but it is an executable. Is the code available anywhere?

 

My fear is that the code I've written above is terribly inefficient at finding factors. It looks at every number from 1 to the square root of the number in question and divides it checking to see if the result is an integer. I don't know the best way to find factors, but I wouldn't be surprised if there's a much more computationally efficient way than that.

 

The problem, or at least my problem, with the Numberator software is that it saves all the elements of all the Unusual Sets, not just Strange Numbers or even their anamolies, in a single Notepad file and that file got so huge on my machine (10+megabytes!!) that I could not even open it as it would lock up the machine. :gift: :hihi:

 

Is a "strange number" one that is abundant by 12? Also, what is an unusual set? Sorry, I'm playing catch-up here.

 

I'm also curious how these 2 conjectures are related:

  1. All odd powers of 2 greater than 32 are at least one Perfect-Square-multiple of a Perfect number plus a Perfect Square.
  2. there exists no way other than sequentially factoring all integers to find Strange Number Anomalies, that is, Strange Numbers not divisible by 6, or not having a factor pair of 6 and a prime.

 

~modest

Posted

It has been a long time since I ran the Numberator. It might take a day just to load up the number file. Here is the code...

Imports System.IO

Public Class Form1
   Inherits System.Windows.Forms.Form
   ' I need to make several functions
   ' one that finds factors
   ' one that adds the factors
   ' one that records the results
   ' then some analysis
   Dim Perfect() As PerfectFamily
   Dim Canceled As Boolean = False
   Dim Target, oldTarget, Loadpoint, OldLoadPoint As Long
   Dim Index As Integer = 2
   Dim Cache As String

#Region " Windows Form Designer generated code "

   Public Sub New()
       MyBase.New()

       'This call is required by the Windows Form Designer.
       InitializeComponent()

       'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.IContainer

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   Friend WithEvents Label1 As System.Windows.Forms.Label
   Friend WithEvents Search As System.Windows.Forms.CheckBox
   Friend WithEvents ListBox3 As System.Windows.Forms.ListBox
   Friend WithEvents Label3 As System.Windows.Forms.Label
   Friend WithEvents Label4 As System.Windows.Forms.Label
   Friend WithEvents Label5 As System.Windows.Forms.Label
   Friend WithEvents Label6 As System.Windows.Forms.Label
   Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
   Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
   Friend WithEvents Label7 As System.Windows.Forms.Label
   Friend WithEvents Timer1 As System.Windows.Forms.Timer
   Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
   Friend WithEvents Button1 As System.Windows.Forms.Button
   Friend WithEvents Button2 As System.Windows.Forms.Button
   Friend WithEvents Button3 As System.Windows.Forms.Button
   Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
   Friend WithEvents GroupBox7 As System.Windows.Forms.GroupBox
   Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
   Friend WithEvents Button4 As System.Windows.Forms.Button
   Friend WithEvents Panel1 As System.Windows.Forms.Panel
   Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
   Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
   Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox
   Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox
   Friend WithEvents Button5 As System.Windows.Forms.Button
   Friend WithEvents NumericUpDown2 As System.Windows.Forms.NumericUpDown
   Friend WithEvents Label2 As System.Windows.Forms.Label
   Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
   Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
   Friend WithEvents Label8 As System.Windows.Forms.Label
   Friend WithEvents Label9 As System.Windows.Forms.Label
   Friend WithEvents BaseList As System.Windows.Forms.ListBox
   Friend WithEvents CheckBox4 As System.Windows.Forms.CheckBox
   Friend WithEvents GroupBox5 As System.Windows.Forms.GroupBox
   Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
   Friend WithEvents Button6 As System.Windows.Forms.Button
   Friend WithEvents Button7 As System.Windows.Forms.Button
   Friend WithEvents CheckBox5 As System.Windows.Forms.CheckBox
   Friend WithEvents CheckBox6 As System.Windows.Forms.CheckBox
   Friend WithEvents CheckBox7 As System.Windows.Forms.CheckBox
   Friend WithEvents Label10 As System.Windows.Forms.Label
   Friend WithEvents Operator1 As System.Windows.Forms.ComboBox
   Friend WithEvents Field1 As System.Windows.Forms.ComboBox
   Friend WithEvents Value1 As System.Windows.Forms.NumericUpDown
   Friend WithEvents ListBox4 As System.Windows.Forms.ListBox
   Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       Me.components = New System.ComponentModel.Container
       Me.Label1 = New System.Windows.Forms.Label
       Me.Search = New System.Windows.Forms.CheckBox
       Me.ListBox3 = New System.Windows.Forms.ListBox
       Me.Label6 = New System.Windows.Forms.Label
       Me.Label5 = New System.Windows.Forms.Label
       Me.Label4 = New System.Windows.Forms.Label
       Me.Label3 = New System.Windows.Forms.Label
       Me.GroupBox2 = New System.Windows.Forms.GroupBox
       Me.BaseList = New System.Windows.Forms.ListBox
       Me.Label9 = New System.Windows.Forms.Label
       Me.Label8 = New System.Windows.Forms.Label
       Me.Label2 = New System.Windows.Forms.Label
       Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown
       Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
       Me.TextBox2 = New System.Windows.Forms.TextBox
       Me.ListBox2 = New System.Windows.Forms.ListBox
       Me.GroupBox3 = New System.Windows.Forms.GroupBox
       Me.CheckBox4 = New System.Windows.Forms.CheckBox
       Me.Label7 = New System.Windows.Forms.Label
       Me.Button4 = New System.Windows.Forms.Button
       Me.Button3 = New System.Windows.Forms.Button
       Me.Button2 = New System.Windows.Forms.Button
       Me.Button1 = New System.Windows.Forms.Button
       Me.TextBox1 = New System.Windows.Forms.TextBox
       Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
       Me.GroupBox7 = New System.Windows.Forms.GroupBox
       Me.GroupBox1 = New System.Windows.Forms.GroupBox
       Me.Panel1 = New System.Windows.Forms.Panel
       Me.GroupBox4 = New System.Windows.Forms.GroupBox
       Me.Button5 = New System.Windows.Forms.Button
       Me.CheckBox3 = New System.Windows.Forms.CheckBox
       Me.CheckBox2 = New System.Windows.Forms.CheckBox
       Me.CheckBox1 = New System.Windows.Forms.CheckBox
       Me.Label10 = New System.Windows.Forms.Label
       Me.GroupBox5 = New System.Windows.Forms.GroupBox
       Me.Value1 = New System.Windows.Forms.NumericUpDown
       Me.Field1 = New System.Windows.Forms.ComboBox
       Me.Operator1 = New System.Windows.Forms.ComboBox
       Me.CheckBox7 = New System.Windows.Forms.CheckBox
       Me.CheckBox6 = New System.Windows.Forms.CheckBox
       Me.CheckBox5 = New System.Windows.Forms.CheckBox
       Me.Button7 = New System.Windows.Forms.Button
       Me.Button6 = New System.Windows.Forms.Button
       Me.ListBox1 = New System.Windows.Forms.ListBox
       Me.ListBox4 = New System.Windows.Forms.ListBox
       Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
       Me.GroupBox2.SuspendLayout()
       CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).BeginInit()
       CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
       Me.GroupBox3.SuspendLayout()
       Me.GroupBox7.SuspendLayout()
       Me.GroupBox1.SuspendLayout()
       Me.GroupBox4.SuspendLayout()
       Me.GroupBox5.SuspendLayout()
       CType(Me.Value1, System.ComponentModel.ISupportInitialize).BeginInit()
       Me.SuspendLayout()
       '
       'Label1
       '
       Me.Label1.Location = New System.Drawing.Point(8, 16)
       Me.Label1.Name = "Label1"
       Me.Label1.Size = New System.Drawing.Size(120, 16)
       Me.Label1.TabIndex = 1
       Me.Label1.Text = "Label1"
       '
       'Search
       '
       Me.Search.Location = New System.Drawing.Point(8, 48)
       Me.Search.Name = "Search"
       Me.Search.Size = New System.Drawing.Size(64, 16)
       Me.Search.TabIndex = 5
       Me.Search.Text = "Search!"
       '
       'ListBox3
       '
       Me.ListBox3.Location = New System.Drawing.Point(8, 16)
       Me.ListBox3.Name = "ListBox3"
       Me.ListBox3.Size = New System.Drawing.Size(120, 82)
       Me.ListBox3.TabIndex = 8
       '
       'Label6
       '
       Me.Label6.Location = New System.Drawing.Point(8, 48)
       Me.Label6.Name = "Label6"
       Me.Label6.Size = New System.Drawing.Size(128, 16)
       Me.Label6.TabIndex = 14
       Me.Label6.Text = "Label6"
       '
       'Label5
       '
       Me.Label5.Location = New System.Drawing.Point(176, 32)
       Me.Label5.Name = "Label5"
       Me.Label5.Size = New System.Drawing.Size(96, 16)
       Me.Label5.TabIndex = 13
       Me.Label5.Text = "Label5"
       '
       'Label4
       '
       Me.Label4.Location = New System.Drawing.Point(144, 48)
       Me.Label4.Name = "Label4"
       Me.Label4.Size = New System.Drawing.Size(128, 16)
       Me.Label4.TabIndex = 12
       Me.Label4.Text = "Label4"
       '
       'Label3
       '
       Me.Label3.Location = New System.Drawing.Point(176, 16)
       Me.Label3.Name = "Label3"
       Me.Label3.Size = New System.Drawing.Size(96, 16)
       Me.Label3.TabIndex = 11
       Me.Label3.Text = "Label3"
       '
       'GroupBox2
       '
       Me.GroupBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                   Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
       Me.GroupBox2.Controls.Add(Me.BaseList)
       Me.GroupBox2.Controls.Add(Me.Label9)
       Me.GroupBox2.Controls.Add(Me.Label8)
       Me.GroupBox2.Controls.Add(Me.Label2)
       Me.GroupBox2.Controls.Add(Me.NumericUpDown2)
       Me.GroupBox2.Controls.Add(Me.NumericUpDown1)
       Me.GroupBox2.Controls.Add(Me.Label6)
       Me.GroupBox2.Controls.Add(Me.Label3)
       Me.GroupBox2.Controls.Add(Me.Label4)
       Me.GroupBox2.Controls.Add(Me.Label5)
       Me.GroupBox2.Controls.Add(Me.TextBox2)
       Me.GroupBox2.Controls.Add(Me.ListBox2)
       Me.GroupBox2.Location = New System.Drawing.Point(144, 168)
       Me.GroupBox2.Name = "GroupBox2"
       Me.GroupBox2.Size = New System.Drawing.Size(280, 224)
       Me.GroupBox2.TabIndex = 11
       Me.GroupBox2.TabStop = False
       Me.GroupBox2.Text = "Selected Number"
       '
       'BaseList
       '
       Me.BaseList.Location = New System.Drawing.Point(120, 104)
       Me.BaseList.Name = "BaseList"
       Me.BaseList.Size = New System.Drawing.Size(88, 30)
       Me.BaseList.TabIndex = 21
       Me.BaseList.Visible = False
       '
       'Label9
       '
       Me.Label9.Location = New System.Drawing.Point(232, 64)
       Me.Label9.Name = "Label9"
       Me.Label9.Size = New System.Drawing.Size(40, 16)
       Me.Label9.TabIndex = 20
       Me.Label9.Text = "k(n)"
       '
       'Label8
       '
       Me.Label8.Location = New System.Drawing.Point(136, 16)
       Me.Label8.Name = "Label8"
       Me.Label8.Size = New System.Drawing.Size(40, 16)
       Me.Label8.TabIndex = 19
       Me.Label8.Text = "k(n)"
       '
       'Label2
       '
       Me.Label2.Location = New System.Drawing.Point(48, 64)
       Me.Label2.Name = "Label2"
       Me.Label2.Size = New System.Drawing.Size(192, 24)
       Me.Label2.TabIndex = 18
       Me.Label2.Text = "Base(10)"
       Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
       '
       'NumericUpDown2
       '
       Me.NumericUpDown2.Location = New System.Drawing.Point(8, 64)
       Me.NumericUpDown2.Maximum = New Decimal(New Integer() {185, 0, 0, 0})
       Me.NumericUpDown2.Minimum = New Decimal(New Integer() {2, 0, 0, 0})
       Me.NumericUpDown2.Name = "NumericUpDown2"
       Me.NumericUpDown2.Size = New System.Drawing.Size(40, 20)
       Me.NumericUpDown2.TabIndex = 17
       Me.NumericUpDown2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
       Me.NumericUpDown2.Value = New Decimal(New Integer() {10, 0, 0, 0})
       '
       'NumericUpDown1
       '
       Me.NumericUpDown1.Location = New System.Drawing.Point(8, 16)
       Me.NumericUpDown1.Maximum = New Decimal(New Integer() {-1530494977, 232830, 0, 0})
       Me.NumericUpDown1.Minimum = New Decimal(New Integer() {1, 0, 0, 0})
       Me.NumericUpDown1.Name = "NumericUpDown1"
       Me.NumericUpDown1.Size = New System.Drawing.Size(128, 20)
       Me.NumericUpDown1.TabIndex = 16
       Me.NumericUpDown1.Value = New Decimal(New Integer() {1, 0, 0, 0})
       '
       'TextBox2
       '
       Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
       Me.TextBox2.Location = New System.Drawing.Point(8, 88)
       Me.TextBox2.Multiline = True
       Me.TextBox2.Name = "TextBox2"
       Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
       Me.TextBox2.Size = New System.Drawing.Size(264, 128)
       Me.TextBox2.TabIndex = 0
       Me.TextBox2.Text = "TextBox2"
       '
       'ListBox2
       '
       Me.ListBox2.Location = New System.Drawing.Point(72, 120)
       Me.ListBox2.Name = "ListBox2"
       Me.ListBox2.Size = New System.Drawing.Size(144, 56)
       Me.ListBox2.TabIndex = 1
       Me.ListBox2.Visible = False
       '
       'GroupBox3
       '
       Me.GroupBox3.Controls.Add(Me.CheckBox4)
       Me.GroupBox3.Controls.Add(Me.Search)
       Me.GroupBox3.Controls.Add(Me.Label1)
       Me.GroupBox3.Controls.Add(Me.Label7)
       Me.GroupBox3.Location = New System.Drawing.Point(8, 8)
       Me.GroupBox3.Name = "GroupBox3"
       Me.GroupBox3.Size = New System.Drawing.Size(136, 72)
       Me.GroupBox3.TabIndex = 12
       Me.GroupBox3.TabStop = False
       Me.GroupBox3.Text = "Searching"
       '
       'CheckBox4
       '
       Me.CheckBox4.Location = New System.Drawing.Point(72, 48)
       Me.CheckBox4.Name = "CheckBox4"
       Me.CheckBox4.Size = New System.Drawing.Size(56, 16)
       Me.CheckBox4.TabIndex = 16
       Me.CheckBox4.Text = "Evens"
       '
       'Label7
       '
       Me.Label7.Location = New System.Drawing.Point(8, 32)
       Me.Label7.Name = "Label7"
       Me.Label7.Size = New System.Drawing.Size(120, 16)
       Me.Label7.TabIndex = 15
       Me.Label7.Text = "#/sec"
       '
       'Button4
       '
       Me.Button4.Location = New System.Drawing.Point(8, 32)
       Me.Button4.Name = "Button4"
       Me.Button4.Size = New System.Drawing.Size(48, 32)
       Me.Button4.TabIndex = 16
       Me.Button4.Text = "Load Values"
       '
       'Button3
       '
       Me.Button3.Location = New System.Drawing.Point(88, 128)
       Me.Button3.Name = "Button3"
       Me.Button3.Size = New System.Drawing.Size(40, 24)
       Me.Button3.TabIndex = 12
       Me.Button3.Text = "Del"
       '
       'Button2
       '
       Me.Button2.Location = New System.Drawing.Point(48, 128)
       Me.Button2.Name = "Button2"
       Me.Button2.Size = New System.Drawing.Size(40, 24)
       Me.Button2.TabIndex = 11
       Me.Button2.Text = "Add"
       '
       'Button1
       '
       Me.Button1.Location = New System.Drawing.Point(8, 128)
       Me.Button1.Name = "Button1"
       Me.Button1.Size = New System.Drawing.Size(40, 24)
       Me.Button1.TabIndex = 10
       Me.Button1.Text = "Edit"
       '
       'TextBox1
       '
       Me.TextBox1.Location = New System.Drawing.Point(8, 104)
       Me.TextBox1.Name = "TextBox1"
       Me.TextBox1.Size = New System.Drawing.Size(120, 20)
       Me.TextBox1.TabIndex = 9
       Me.TextBox1.Text = ""
       '
       'Timer1
       '
       Me.Timer1.Enabled = True
       Me.Timer1.Interval = 1000
       '
       'GroupBox7
       '
       Me.GroupBox7.Controls.Add(Me.ListBox3)
       Me.GroupBox7.Controls.Add(Me.TextBox1)
       Me.GroupBox7.Controls.Add(Me.Button1)
       Me.GroupBox7.Controls.Add(Me.Button2)
       Me.GroupBox7.Controls.Add(Me.Button3)
       Me.GroupBox7.Location = New System.Drawing.Point(8, 184)
       Me.GroupBox7.Name = "GroupBox7"
       Me.GroupBox7.Size = New System.Drawing.Size(136, 160)
       Me.GroupBox7.TabIndex = 15
       Me.GroupBox7.TabStop = False
       Me.GroupBox7.Text = "Strange Names"
       '
       'GroupBox1
       '
       Me.GroupBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                   Or System.Windows.Forms.AnchorStyles.Left) _
                   Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
       Me.GroupBox1.Controls.Add(Me.Panel1)
       Me.GroupBox1.Location = New System.Drawing.Point(424, 8)
       Me.GroupBox1.Name = "GroupBox1"
       Me.GroupBox1.Size = New System.Drawing.Size(472, 384)
       Me.GroupBox1.TabIndex = 16
       Me.GroupBox1.TabStop = False
       Me.GroupBox1.Text = "Strange Analysis"
       '
       'Panel1
       '
       Me.Panel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                   Or System.Windows.Forms.AnchorStyles.Left) _
                   Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
       Me.Panel1.AutoScroll = True
       Me.Panel1.Location = New System.Drawing.Point(0, 16)
       Me.Panel1.Name = "Panel1"
       Me.Panel1.Size = New System.Drawing.Size(472, 366)
       Me.Panel1.TabIndex = 1
       '
       'GroupBox4
       '
       Me.GroupBox4.Controls.Add(Me.Button5)
       Me.GroupBox4.Controls.Add(Me.CheckBox3)
       Me.GroupBox4.Controls.Add(Me.CheckBox2)
       Me.GroupBox4.Controls.Add(Me.CheckBox1)
       Me.GroupBox4.Controls.Add(Me.Button4)
       Me.GroupBox4.Controls.Add(Me.Label10)
       Me.GroupBox4.Location = New System.Drawing.Point(8, 80)
       Me.GroupBox4.Name = "GroupBox4"
       Me.GroupBox4.Size = New System.Drawing.Size(136, 104)
       Me.GroupBox4.TabIndex = 17
       Me.GroupBox4.TabStop = False
       Me.GroupBox4.Text = "Load/List Numbers"
       '
       'Button5
       '
       Me.Button5.Enabled = False
       Me.Button5.Location = New System.Drawing.Point(8, 64)
       Me.Button5.Name = "Button5"
       Me.Button5.Size = New System.Drawing.Size(48, 32)
       Me.Button5.TabIndex = 20
       Me.Button5.Text = "Cancel"
       '
       'CheckBox3
       '
       Me.CheckBox3.Location = New System.Drawing.Point(64, 80)
       Me.CheckBox3.Name = "CheckBox3"
       Me.CheckBox3.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox3.TabIndex = 19
       Me.CheckBox3.Text = "Strange"
       '
       'CheckBox2
       '
       Me.CheckBox2.Checked = True
       Me.CheckBox2.CheckState = System.Windows.Forms.CheckState.Checked
       Me.CheckBox2.Location = New System.Drawing.Point(64, 56)
       Me.CheckBox2.Name = "CheckBox2"
       Me.CheckBox2.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox2.TabIndex = 18
       Me.CheckBox2.Text = "Anomalous"
       '
       'CheckBox1
       '
       Me.CheckBox1.Checked = True
       Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Checked
       Me.CheckBox1.Location = New System.Drawing.Point(64, 32)
       Me.CheckBox1.Name = "CheckBox1"
       Me.CheckBox1.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox1.TabIndex = 17
       Me.CheckBox1.Text = "Perfect"
       '
       'Label10
       '
       Me.Label10.Location = New System.Drawing.Point(8, 16)
       Me.Label10.Name = "Label10"
       Me.Label10.Size = New System.Drawing.Size(120, 16)
       Me.Label10.TabIndex = 17
       Me.Label10.Text = "Label10"
       '
       'GroupBox5
       '
       Me.GroupBox5.Controls.Add(Me.ProgressBar1)
       Me.GroupBox5.Controls.Add(Me.Value1)
       Me.GroupBox5.Controls.Add(Me.Field1)
       Me.GroupBox5.Controls.Add(Me.Operator1)
       Me.GroupBox5.Controls.Add(Me.CheckBox7)
       Me.GroupBox5.Controls.Add(Me.CheckBox6)
       Me.GroupBox5.Controls.Add(Me.CheckBox5)
       Me.GroupBox5.Controls.Add(Me.Button7)
       Me.GroupBox5.Controls.Add(Me.Button6)
       Me.GroupBox5.Controls.Add(Me.ListBox1)
       Me.GroupBox5.Controls.Add(Me.ListBox4)
       Me.GroupBox5.Location = New System.Drawing.Point(144, 8)
       Me.GroupBox5.Name = "GroupBox5"
       Me.GroupBox5.Size = New System.Drawing.Size(280, 160)
       Me.GroupBox5.TabIndex = 18
       Me.GroupBox5.TabStop = False
       Me.GroupBox5.Text = "Find Tool"
       '
       'Value1
       '
       Me.Value1.Location = New System.Drawing.Point(224, 16)
       Me.Value1.Name = "Value1"
       Me.Value1.Size = New System.Drawing.Size(48, 20)
       Me.Value1.TabIndex = 9
       '
       'Field1
       '
       Me.Field1.Items.AddRange(New Object() {"Pairs", "Count Prime Factors", "Has Prime Factor"})
       Me.Field1.Location = New System.Drawing.Point(120, 16)
       Me.Field1.Name = "Field1"
       Me.Field1.Size = New System.Drawing.Size(64, 21)
       Me.Field1.TabIndex = 8
       Me.Field1.Text = "ComboBox2"
       '
       'Operator1
       '
       Me.Operator1.Items.AddRange(New Object() {"<", ">", "=", "<=", ">=", "<>"})
       Me.Operator1.Location = New System.Drawing.Point(184, 16)
       Me.Operator1.Name = "Operator1"
       Me.Operator1.Size = New System.Drawing.Size(40, 21)
       Me.Operator1.TabIndex = 7
       Me.Operator1.Text = "ComboBox1"
       '
       'CheckBox7
       '
       Me.CheckBox7.Location = New System.Drawing.Point(56, 48)
       Me.CheckBox7.Name = "CheckBox7"
       Me.CheckBox7.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox7.TabIndex = 5
       Me.CheckBox7.Text = "Strange"
       '
       'CheckBox6
       '
       Me.CheckBox6.Location = New System.Drawing.Point(56, 32)
       Me.CheckBox6.Name = "CheckBox6"
       Me.CheckBox6.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox6.TabIndex = 4
       Me.CheckBox6.Text = "Anomalous"
       '
       'CheckBox5
       '
       Me.CheckBox5.Location = New System.Drawing.Point(56, 16)
       Me.CheckBox5.Name = "CheckBox5"
       Me.CheckBox5.Size = New System.Drawing.Size(64, 16)
       Me.CheckBox5.TabIndex = 3
       Me.CheckBox5.Text = "Perfect"
       '
       'Button7
       '
       Me.Button7.Location = New System.Drawing.Point(8, 16)
       Me.Button7.Name = "Button7"
       Me.Button7.Size = New System.Drawing.Size(40, 24)
       Me.Button7.TabIndex = 2
       Me.Button7.Text = "Find"
       '
       'Button6
       '
       Me.Button6.Location = New System.Drawing.Point(8, 40)
       Me.Button6.Name = "Button6"
       Me.Button6.Size = New System.Drawing.Size(40, 24)
       Me.Button6.TabIndex = 1
       Me.Button6.Text = "Clear"
       '
       'ListBox1
       '
       Me.ListBox1.Location = New System.Drawing.Point(128, 72)
       Me.ListBox1.Name = "ListBox1"
       Me.ListBox1.Size = New System.Drawing.Size(144, 82)
       Me.ListBox1.TabIndex = 0
       '
       'ListBox4
       '
       Me.ListBox4.Location = New System.Drawing.Point(8, 72)
       Me.ListBox4.Name = "ListBox4"
       Me.ListBox4.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple
       Me.ListBox4.Size = New System.Drawing.Size(112, 82)
       Me.ListBox4.TabIndex = 13
       '
       'ProgressBar1
       '
       Me.ProgressBar1.Location = New System.Drawing.Point(120, 48)
       Me.ProgressBar1.Name = "ProgressBar1"
       Me.ProgressBar1.Size = New System.Drawing.Size(152, 16)
       Me.ProgressBar1.TabIndex = 14
       '
       'Form1
       '
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.AutoScroll = True
       Me.ClientSize = New System.Drawing.Size(904, 398)
       Me.Controls.Add(Me.GroupBox5)
       Me.Controls.Add(Me.GroupBox4)
       Me.Controls.Add(Me.GroupBox1)
       Me.Controls.Add(Me.GroupBox7)
       Me.Controls.Add(Me.GroupBox3)
       Me.Controls.Add(Me.GroupBox2)
       Me.MaximumSize = New System.Drawing.Size(1600, 432)
       Me.MinimumSize = New System.Drawing.Size(640, 432)
       Me.Name = "Form1"
       Me.Text = "Form1"
       Me.GroupBox2.ResumeLayout(False)
       CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).EndInit()
       CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
       Me.GroupBox3.ResumeLayout(False)
       Me.GroupBox7.ResumeLayout(False)
       Me.GroupBox1.ResumeLayout(False)
       Me.GroupBox4.ResumeLayout(False)
       Me.GroupBox5.ResumeLayout(False)
       CType(Me.Value1, System.ComponentModel.ISupportInitialize).EndInit()
       Me.ResumeLayout(False)

   End Sub

#End Region
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.Text = "Numberator 2.4 - Searcher for strange numbers..."
       Dim Line As String
       SetBaseList()
       If File.Exists("StrangeNames.txt") = True Then
           Dim sw As StreamReader
           sw = File.OpenText("StrangeNames.txt")
           Line = sw.ReadLine
           Do Until Line = ""
               ListBox3.Items.Add(Line)
               ListBox4.Items.Add(Line)
               Line = sw.ReadLine
           Loop
           sw.Close()
       End If
       If File.Exists("Next.txt") = True Then
           Dim sw As StreamReader
           sw = File.OpenText("Next.txt")
           Target = sw.ReadLine
           sw.Close()
       End If
       Panel1.Left = 2
       Panel1.Width = Panel1.Parent.Width - 4
       Label1.Text = Target

   End Sub
   Sub TextUpdate(ByVal textbox As TextBox, ByVal num As Number)
       Dim st As String
       st = num.Number & " - "
       For x As Integer = 1 To num.Factors.Length
           st = st & num.Factors(x - 1) & ", "
       Next
       st = Mid(st, 1, Len(st) - 2) & " - " & num.FSum
       st = st & ControlChars.CrLf
       textbox.AppendText(st)
   End Sub
   Sub LabelUpdate(ByVal label As Label, ByVal num As Number)
       Dim st As String
       st = num.Number & " - "
       For x As Integer = 1 To num.Factors.Length
           st = st & num.Factors(x - 1) & ", "
       Next
       st = Mid(st, 1, Len(st) - 2) & " - " & num.FSum
       label.Text = st
   End Sub
   Private Sub Search_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.CheckedChanged
       Select Case Search.Checked
           Case True
               If Perfect Is Nothing Then
                   CheckBox1.Checked = True
                   CheckBox2.Checked = True
                   LoadNumbers()
               End If
           Case False
               If Not Cache Is Nothing Then
                   If Cache.Length > 0 Then DumpCache("Numbers.txt")
               End If

       End Select

       GroupBox4.Enabled = Not Search.Checked
       Search.Refresh()
       ProgressiveScan()
   End Sub
   Sub ProgressiveScan()
       'Check which number to use as the next number
       Dim Doit As Integer
       Dim start As Date = Now
       Do While Search.Checked = True
           Target += Index
           CheckNumber(Target, True)

           Doit += 1
           If Doit > 99 Then
               Application.DoEvents()
               Doit = 0
           End If

       Loop
       Dim finish As Date = Now
   End Sub
   Sub CheckNumber(ByVal Num As Long, ByVal Write As Boolean)

       Label1.Text = Num
       Label1.Refresh()
       Dim Perf As Integer
       Dim Temp As New Number
       Temp.SetNum(Num)
       If Temp.Type = "Perfect" Then
           AddPerfect(Num, Write)
           Exit Sub
       End If

       If Perfect Is Nothing Then Exit Sub

       For x As Integer = 0 To Perfect.Length - 1
           If Perfect(x).value * 2 = Temp.FDif Then
               Temp.Type = Perfect(x).Text
               Perf = x
           End If
       Next

       If Temp.Type <> "" Then

           For x As Integer = 0 To Temp.Factors.Length - 1
               If Perfect(Perf).Value = Temp.Factors(x) Then
                   AddStrange(Num, Write, Perf)
                   Exit Sub
               End If
           Next

           AddException(Num, Write, Perf)

       End If
   End Sub
   Sub ListClick(ByVal sender As System.Object, ByVal e As System.EventArgs, ByVal ID As Integer, ByVal Type As String)
       Select Case Type
           Case "Anomalous"
               If Perfect(ID).AnomalyList.SelectedIndex = -1 Then Exit Sub
               UpdateDetails(Perfect(ID).AnomalyList.Items(Perfect(ID).AnomalyList.SelectedIndex), ID)
           Case "Strange"
               If Perfect(ID).StrangeList.SelectedIndex = -1 Then Exit Sub
               UpdateDetails(Perfect(ID).StrangeList.Items(Perfect(ID).StrangeList.SelectedIndex), ID)
       End Select
   End Sub
   Sub AddPerfect(ByVal Num As Long, ByVal write As Boolean)

       If Not Perfect Is Nothing Then
           For y As Integer = 0 To Perfect.Length - 1
               If Perfect(y).Value = Num Then Exit Sub
           Next
       End If

       Dim Gap As Integer = 4

       If Perfect Is Nothing Then
           ReDim Perfect(0)
       Else
           ReDim Preserve Perfect(Perfect.Length)
       End If
       Dim x As Integer = Perfect.Length - 1
       Dim temp As New PerfectFamily
       Perfect(x) = temp
       Me.Controls.Add(Perfect(x))
       With Perfect(x)
           .Value = Num
           If ListBox3.Items.Count - 1 < x Then
               ListBox3.Items.Add(Perfect(x).Value)
               ListBox4.Items.Add(Perfect(x).Value)
           End If

           .Type = ListBox3.Items(x)
           .Text = .Type & " - Perfect number = " & .Value
           .Parent = Panel1
           .Top = 0
           .Width = 264
           .Height = .Parent.Height - .Top - 17
           .Left = Gap + (x * (.Width + Gap))
           .ID = x

           Dim tempLabel2 As New Label
           .StrangeCount = tempLabel2
           Me.Controls.Add(.StrangeCount)
           .StrangeCount.Parent = Perfect(x)
           .StrangeCount.Top = 16
           .StrangeCount.Left = 2
           .StrangeCount.Height = 16
           .StrangeCount.Width = .StrangeCount.Parent.Width / 2 - 4
           .StrangeCount.BackColor = Color.Beige
           .StrangeCount.Text = .Type & ": "

           Dim tempLabel3 As New Label
           .AnomalyCount = tempLabel3
           Me.Controls.Add(.AnomalyCount)
           .AnomalyCount.Parent = Perfect(x)
           .AnomalyCount.Top = 16
           .AnomalyCount.Height = 16
           .AnomalyCount.Width = .AnomalyCount.Parent.Width / 2 - 4
           .AnomalyCount.Left = .AnomalyCount.Parent.Width / 2 + 2
           .AnomalyCount.BackColor = Color.Aqua
           .AnomalyCount.Text = "Anomalous: "

           Dim tempList1 As New PerfectList
           .StrangeList = tempList1
           Me.Controls.Add(.StrangeList)
           .StrangeList.Parent = Perfect(x)
           AddHandler Perfect(x).StrangeList.List_Click, AddressOf ListClick
           .StrangeList.ID = x
           .StrangeList.Type = "Strange"
           .StrangeList.Height = 82
           .StrangeList.Top = .StrangeCount.Top + .StrangeCount.Height + 2
           .StrangeList.Left = .StrangeCount.Left
           .StrangeList.Width = .StrangeCount.Width
           .StrangeList.MultiColumn = False
           .StrangeList.HorizontalScrollbar = False
           .StrangeList.ScrollAlwaysVisible = False

           Dim templist2 As New PerfectList
           .AnomalyList = templist2
           Me.Controls.Add(.AnomalyList)
           .AnomalyList.Parent = Perfect(x)
           AddHandler Perfect(x).AnomalyList.List_Click, AddressOf ListClick
           .AnomalyList.ID = x
           .AnomalyList.Type = "Anomalous"
           .AnomalyList.Height = 82
           .AnomalyList.Top = .StrangeList.Top
           .AnomalyList.Left = .AnomalyCount.Left
           .AnomalyList.Width = .AnomalyCount.Width
           .AnomalyList.MultiColumn = False
           .AnomalyList.HorizontalScrollbar = False
           .AnomalyList.ScrollAlwaysVisible = False

           Dim tempLabel1 As New Label
           .Selected = tempLabel1
           Me.Controls.Add(.Selected)
           .Selected.Parent = Perfect(x)
           .Selected.Top = .AnomalyList.Top + .AnomalyList.Height + 2
           .Selected.Left = 2
           .Selected.Width = .Selected.Parent.Width * 0.8333 - 4
           .Selected.Height = 16
           .Selected.Text = "Selected: "
           .Selected.BackColor = Color.Cornsilk

           Dim tempLabel8 As New Label
           .Katabatak = tempLabel8
           Me.Controls.Add(.Katabatak)
           .Katabatak.Parent = Perfect(x)
           .Katabatak.Top = .Selected.Top
           .Katabatak.Left = .Selected.Left + .Selected.Width
           .Katabatak.Height = 16
           .Katabatak.Width = .Katabatak.Parent.Width - .Selected.Width - 4
           .Katabatak.Text = "k(n): "
           .Katabatak.BackColor = Color.Cyan
           .Katabatak.TextAlign = ContentAlignment.MiddleLeft

           Dim tempBase As New PerfectBase
           .Base = tempBase
           Me.Controls.Add(.Base)
           .Base.ID = x
           .Base.Parent = Perfect(x)
           .Base.Top = .Selected.Top + .Selected.Height + 2
           .Base.Left = 2
           .Base.Width = .Base.Parent.Width / 6 - 4
           .Base.TextAlign = HorizontalAlignment.Right
           .Base.Value = 10
           .Base.Text = 10
           .Base.Minimum = 2
           .Base.Maximum = 185
           AddHandler Perfect(x).Base.P_ValueChanged, AddressOf SetBase

           Dim tempLabel7 As New Label
           .OffBase = tempLabel7
           Me.Controls.Add(.OffBase)
           .OffBase.Parent = Perfect(x)
           .OffBase.Height = 16
           .OffBase.Top = .Base.Top + ((.Base.Height - .OffBase.Height) / 2)
           .OffBase.Left = .Base.Left + .Base.Width
           .OffBase.Width = .Katabatak.Left - .OffBase.Left
           .OffBase.Text = "Base(" & .Base.Text & "): "
           .OffBase.BackColor = Color.DeepPink
           .OffBase.TextAlign = ContentAlignment.MiddleLeft

           Dim tempLabel9 As New Label
           .BaseKatabatak = tempLabel9
           Me.Controls.Add(.BaseKatabatak)
           .BaseKatabatak.Parent = Perfect(x)
           .BaseKatabatak.Height = 16
           .BaseKatabatak.Top = .OffBase.Top
           .BaseKatabatak.Left = .Katabatak.Left
           .BaseKatabatak.Width = .Katabatak.Width
           .BaseKatabatak.Text = "k(n): "
           .BaseKatabatak.BackColor = Color.Gainsboro
           .BaseKatabatak.TextAlign = ContentAlignment.MiddleLeft

           Dim tempLabel4 As New Label
           .Pairs = tempLabel4
           Me.Controls.Add(.Pairs)
           .Pairs.Parent = Perfect(x)
           .Pairs.Height = 16
           .Pairs.Top = .Base.Top + .Base.Height + 2
           .Pairs.Left = 2
           .Pairs.Text = "Pairs: "
           .Pairs.BackColor = Color.Goldenrod
           .Pairs.TextAlign = ContentAlignment.MiddleLeft

           Dim tempLabel5 As New Label
           .Sum = tempLabel5
           Me.Controls.Add(.Sum)
           .Sum.Parent = Perfect(x)
           .Sum.Height = 16
           .Sum.Top = .Pairs.Top + .Pairs.Height + 2
           .Sum.Left = 2
           .Sum.Text = "Sum: "
           .Sum.BackColor = Color.Honeydew
           .Sum.TextAlign = ContentAlignment.MiddleLeft

           Dim tempLabel6 As New Label
           .Dif = tempLabel6
           Me.Controls.Add(.Dif)
           .Dif.Parent = Perfect(x)
           .Dif.Height = 16
           .Dif.Top = .Sum.Top + .Sum.Height + 2
           .Dif.Left = 2
           .Dif.Text = "Dif: "
           .Dif.BackColor = Color.Khaki
           .Dif.TextAlign = ContentAlignment.MiddleLeft

           Dim tempTextbox1 As New TextBox
           .Factors = tempTextbox1
           Me.Controls.Add(.Factors)
           .Factors.Parent = Perfect(x)
           .Factors.Multiline = True
           .Factors.WordWrap = True
           .Factors.ScrollBars = ScrollBars.Vertical
           .Factors.Left = 8
           .Factors.Size = TextBox2.Size
           .Factors.Top = .Factors.Parent.Height - .Factors.Height - 8

       End With
       If write = True Then Append("Numbers.txt", "PN" & Num)

       'ListBox2.Items.Add(Num)
       'GroupBox4.Text = "Perfect Numbers: " & ListBox2.Items.Count
   End Sub
   Sub SetBase(ByVal sender As System.Object, ByVal e As System.EventArgs, ByVal ID As Integer)
       If Perfect(ID).SelVal < 2 Then Exit Sub
       UpdateDetails(Perfect(ID).SelVal, ID)
   End Sub
   Sub AddException(ByVal Num As Long, ByVal write As Boolean, ByVal Perf As Integer)
       'ListBox4.Items.Add(Num)
       'GroupBox1.Text = "Known Exceptions: " & ListBox4.Items.Count
       Perfect(Perf).AnomalyList.Items.Add(Num)
       Perfect(Perf).AnomalyCount.Text = "Anomalous: " & Perfect(Perf).AnomalyList.Items.Count
       If write = True Then Append("Numbers.txt", Perf & "A" & Num)
   End Sub
   Sub AddStrange(ByVal Num As Long, ByVal write As Boolean, ByVal Perf As Integer)
       'ListBox1.Items.Add(Num)
       'GroupBox5.Text = "Strangers: " & ListBox1.Items.Count
       If CheckBox3.Checked = True Then
           Perfect(Perf).StrangeList.Items.Add(Num)
           Perfect(Perf).StrangeCount.Text = Perfect(Perf).Type & ": " & Perfect(Perf).StrangeList.Items.Count
       End If
       If write = True Then Append("Numbers.txt", Perf & "S" & Num)
   End Sub
   Sub Append(ByVal fName As String, ByVal Line As String)
       If Cache <> "" Then
           Cache = Cache & ControlChars.CrLf & Line
       Else
           Cache = Cache & Line
       End If
       If Cache.Length > 1024 Then DumpCache(fName)
   End Sub
   Sub DumpCache(ByVal fname As String)
       Dim sw As StreamWriter
       sw = File.AppendText(fname)
       sw.WriteLine(Cache)
       Cache = ""
       sw.Close()
   End Sub
   Sub UpdateDetails(ByVal num As Long, Optional ByVal ID As Integer = -1)

       Select Case ID
           Case -1
               Dim temp As New Number
               temp.SetNum(num)
               Label3.Text = "Sum: " & temp.FSum
               Label4.Text = "Dif: " & temp.FDif
               Label5.Text = "Pairs: " & temp.FPairs

               For x As Integer = 0 To Perfect.Length - 1
                   If Perfect(x).Value * 2 = temp.FDif Then
                       temp.Type = Perfect(x).Type
                   End If
               Next

               Label6.Text = "Type: " & temp.Type
               Label8.Text = "k(n)= " & k10(temp.Number)
               Label9.Text = "k(n)= " & k10(temp.Number, NumericUpDown2.Value)
               Label2.Text = "Base(" & NumericUpDown2.Value & ")" & Base(NumericUpDown2.Value, NumericUpDown1.Value)

               TextBox2.Text = temp.Factors(0) '& ", " & temp.Number
               For x As Integer = 1 To temp.Factors.Length - 1
                   TextBox2.Text = TextBox2.Text & ", " & temp.Factors(x)
               Next
               TextBox2.Text = TextBox2.Text & ControlChars.CrLf & ControlChars.CrLf & PrimeFactors(num)

           Case Else
               With Perfect(ID)
                   Dim temp As New Number
                   temp.SetNum(num)
                   .SelVal = temp.Number
                   .Selected.Text = "Selected: " & temp.Number
                   .Sum.Text = "Sum: " & temp.FSum
                   .Dif.Text = "Dif: " & temp.FDif
                   .Pairs.Text = "Pairs: " & temp.FPairs
                   .Katabatak.Text = "k(n)= " & k10(temp.Number)
                   .BaseKatabatak.Text = "k(n)= " & k10(temp.Number, .Base.Value)
                   .OffBase.Text = "Base(" & .Base.Value & ")" & Base(.Base.Value, temp.Number)
                   .Factors.Text = temp.Factors(0) '& ", " & temp.Number
                   For x As Integer = 1 To temp.Factors.Length - 1
                       .Factors.Text = .Factors.Text & ", " & temp.Factors(x)
                   Next
                   .Factors.Text = .Factors.Text & ControlChars.CrLf & ControlChars.CrLf & PrimeFactors(num)

               End With
       End Select

   End Sub
   Sub SetDetails(ByVal num As Long)

   End Sub
   Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

       If Not Cache Is Nothing Then
           If Cache.Length > 0 Then DumpCache("Numbers.txt")
       End If

       Dim sw As StreamWriter
       Dim name As String

       name = "Next.txt"
       If File.Exists(name) = True Then File.Delete(name)
       sw = File.AppendText(name)
       sw.WriteLine(Target)
       sw.Close()
   End Sub
   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       Select Case Search.Checked
           Case True
               Label7.Text = "#/sec = " & Target - oldTarget
               oldTarget = Target
           Case False
               Label7.Text = "#/sec = " & Loadpoint - OldLoadPoint
               OldLoadPoint = Loadpoint
       End Select
       Label7.Refresh()
   End Sub
   Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
       'CheckNumber(NumericUpDown1.Value)
       If Perfect Is Nothing Then Exit Sub
       ListBox2.Items.Clear()
       ListBox2.Items.Add(NumericUpDown1.Value)
       ListBox2.SelectedIndex = 0
       UpdateDetails(NumericUpDown1.Value)
   End Sub
   Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'Check if any item is selected in the listbox
       If ListBox3.SelectedIndex = -1 Then Exit Sub
       If Trim(TextBox1.Text) = "" Then Exit Sub
       ListBox3.Items(ListBox3.SelectedIndex) = TextBox1.Text
       ListBox4.Items(ListBox3.SelectedIndex) = TextBox1.Text
       UpdatePerfectNames()
   End Sub
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       If Trim(TextBox1.Text) = "" Then Exit Sub
       ListBox3.Items.Add(TextBox1.Text)
       ListBox4.Items.Add(TextBox1.Text)
       UpdatePerfectNames()
   End Sub
   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
       If ListBox3.SelectedIndex = -1 Then Exit Sub
       ListBox3.Items.Remove(ListBox3.Items(ListBox3.SelectedIndex))
       ListBox4.Items.Remove(ListBox3.Items(ListBox3.SelectedIndex))
       UpdatePerfectNames()
   End Sub
   Sub UpdatePerfectNames()
       For x As Integer = 0 To Perfect.Length - 1
           With Perfect(x)
               If ListBox3.Items.Count - 1 < x Then
                   ListBox3.Items.Add(Perfect(x).Value)
                   ListBox4.Items.Add(Perfect(x).Value)
               End If

               .Type = ListBox3.Items(x)
               .Text = .Type & " - Perfect number = " & .Value
           End With
       Next

       Dim fName As String = "StrangeNames.txt"
       If File.Exists(fName) Then
           File.Delete(fName)
       End If
       For x As Integer = 0 To ListBox3.Items.Count - 1
           Append(fName, ListBox3.Items(x))
       Next
   End Sub
   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

       If Not Perfect Is Nothing Or CheckBox1.Checked = True Then LoadNumbers()

   End Sub
   Sub LoadNumbers()

       ClearLists()

       For Each b As Control In GroupBox4.Controls
           b.Enabled = Not b.Enabled
       Next

       If File.Exists("Numbers.txt") = False Then Exit Sub

       Dim Line As String
       Dim sr As StreamReader
       Dim a As Long
       Dim y As Long

       sr = File.OpenText("Numbers.txt")

       Line = sr.ReadLine()
       Do Until Line = ""
           a += 1
           Line = sr.ReadLine
       Loop
       sr.Close()

       If a = 0 Then Exit Sub
       sr = File.OpenText("Numbers.txt")
       'GroupBox3.Text = "Loading"
       For Each z As Control In GroupBox3.Controls
           z.Enabled = False
       Next

       For x As Integer = 1 To a
           Line = sr.ReadLine
           'CheckNumber(Line.Substring(2), False)
           Select Case Line.Chars(1)
               Case "N"
                   If CheckBox1.Checked = True Then
                       AddPerfect(Line.Substring(2), False)
                   End If

               Case "S"
                   If CheckBox3.Checked = True Then
                       AddStrange(Line.Substring(2), False, CStr(Line.Chars(0)))
                   End If

               Case "A"
                   If CheckBox2.Checked = True Then
                       AddException(Line.Substring(2), False, CStr(Line.Chars(0)))
                   End If

           End Select

           Label10.Text = x & "/" & a
           Label10.Refresh()

           y += 1
           If y > 1000 Then
               Application.DoEvents()
               y = 0
           End If

           If Canceled = True Then
               ClearLists()
               Canceled = False
               Exit For
           End If
           Loadpoint += 1
       Next
       sr.Close()

       'GroupBox3.Text = "Search"
       For Each z As Control In GroupBox3.Controls
           z.Enabled = True
       Next
       For Each b As Control In GroupBox4.Controls
           b.Enabled = Not b.Enabled
       Next

       Label1.Text = Target

   End Sub
   Sub ClearLists()
       If Not Perfect Is Nothing Then
           For Each c As PerfectFamily In Perfect
               If CheckBox2.Checked = True Then
                   c.AnomalyList.Items.Clear()
                   c.AnomalyCount.Text = "Anomalous: " & c.AnomalyList.Items.Count
               End If

               If CheckBox3.Checked = True Then
                   c.StrangeList.Items.Clear()
                   c.StrangeCount.Text = c.Type & ": " & c.StrangeList.Items.Count
               End If
           Next
       End If
   End Sub

   Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
       Canceled = True
   End Sub
   Function k10(ByVal num As Long, Optional ByVal b As Integer = 10) As String
       Dim bNum As String = Base(b, num)
       Dim y As Integer
       Do
           y = 0
           For x As Integer = 0 To Len(bNum) - 1
               y += cVal(bNum.Substring(x, 1))
           Next
           bNum = Base(b, y)
       Loop Until Len(bNum) = 1
       Return bNum
   End Function
   Function cVal(ByVal digit As String) As Integer
       Return BaseList.FindStringExact(digit)
   End Function
   Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged
       If BaseList.Items.Count <> 0 Then UpdateDetails(NumericUpDown1.Value)
   End Sub
   Function Base(ByVal b As Integer, ByVal num As Long) As String
       Dim x As Integer = 0
       Dim z As Integer
       Dim bNum As String = ""

       Do Until b ^ x > num
           x += 1
       Loop

       For y As Integer = x - 1 To 0 Step -1
           z = 0
           Do Until num < b ^ y
               num -= b ^ y
               z += 1
           Loop
           bNum = bNum & BaseList.Items(z)
       Next
       Return bNum
   End Function
   Sub SetBaseList()
       Dim x As Integer
       For x = 48 To 57
           BaseList.Items.Add(Chr(x))
       Next
       For x = 65 To 90
           BaseList.Items.Add(Chr(x))
       Next
       For x = 97 To 122
           BaseList.Items.Add(Chr(x))
       Next
       For x = 33 To 47
           BaseList.Items.Add(Chr(x))
       Next
       For x = 58 To 64
           BaseList.Items.Add(Chr(x))
       Next
       For x = 91 To 96
           BaseList.Items.Add(Chr(x))
       Next
       For x = 161 To 255
           BaseList.Items.Add(Chr(x))
       Next
       x = BaseList.Items.Count
   End Sub
   Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
       Select Case CheckBox4.Checked
           Case True
               If Target / 2 <> Int(Target / 2) Then
                   Target -= 1
               End If
               Index = 2
           Case False
               Index = 1
       End Select
   End Sub
   Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
       ListBox1.Items.Clear()

       'Dim sr As StreamReader
       'sr = File.OpenText("Numbers1.txt")
       'Dim sw As StreamWriter
       'sw = File.AppendText("Numbers2.txt")

       'Dim temp As String
       'Dim Line As String
       'Do
       '    Line = sr.ReadLine()
       '    If Line <> "" Then sw.WriteLine(Line)

       'Loop Until Line = "0S34907442"
       'sr.Close()

       'sw.Close()

   End Sub

   Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
       If ListBox1.SelectedIndex <> -1 Then NumericUpDown1.Value = ListBox1.Items(ListBox1.SelectedIndex)
   End Sub

   Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
       If Perfect Is Nothing Then Exit Sub
       Button7.Enabled = False
       Button6.Enabled = False
       ProgressBar1.Maximum = 0
       ProgressBar1.Value = 0
       For Each w As Integer In ListBox4.SelectedIndices
           If w > Perfect.Length - 1 Then Exit For
           Dim v As New PerfectFamily
           v = Perfect(w)
           If CheckBox5.Checked = True Then ProgressBar1.Maximum += 1
           If CheckBox6.Checked = True Then ProgressBar1.Maximum += v.AnomalyList.Items.Count
           If CheckBox7.Checked = True Then ProgressBar1.Maximum += v.StrangeList.Items.Count
       Next
       For Each z As Integer In ListBox4.SelectedIndices
           If z > Perfect.Length - 1 Then Exit For
           Dim x As New PerfectFamily
           x = Perfect(z)
           If CheckBox5.Checked = True Then
               ProgressBar1.Value += 1
               If CheckFind(x.Value) = True Then ListBox1.Items.Add(x.Value)
           End If

           If CheckBox6.Checked = True Then
               For Each y As String In x.AnomalyList.Items
                   ProgressBar1.Value += 1
                   If CheckFind(y) = True Then
                       ListBox1.Items.Add(y)
                   End If
               Next
           End If

           If CheckBox7.Checked = True Then
               For Each y As String In x.StrangeList.Items
                   ProgressBar1.Value += 1
                   If CheckFind(y) = True Then
                       ListBox1.Items.Add(y)
                   End If
               Next
           End If
           Application.DoEvents()
       Next
       Button7.Enabled = True
       Button6.Enabled = True
       ProgressBar1.Value = 0
   End Sub
   Function CheckFind(ByVal num As Long) As Boolean

       If Field1.SelectedIndex = -1 Or Operator1.SelectedIndex = -1 Then Return False
       Dim temp As New Number
       temp.SetNum(num)

       Select Case Field1.SelectedIndex
           Case 0
               Select Case Operator1.SelectedIndex
                   Case 0
                       If temp.FPairs < Value1.Value Then Return True
                   Case 1
                       If temp.FPairs > Value1.Value Then Return True
                   Case 2
                       If temp.FPairs = Value1.Value Then Return True
                   Case 3
                       If temp.FPairs <= Value1.Value Then Return True
                   Case 4
                       If temp.FPairs >= Value1.Value Then Return True
                   Case 5
                       If temp.FPairs <> Value1.Value Then Return True
               End Select
           Case 1
               Dim y As Integer
               For Each x As Char In PrimeFactors(num)
                   If x.ToString = "(" Then y += 1
               Next
               Select Case Operator1.SelectedIndex
                   Case 0
                       If y < Value1.Value Then Return True
                   Case 1
                       If y > Value1.Value Then Return True
                   Case 2
                       If y = Value1.Value Then Return True
                   Case 3
                       If y <= Value1.Value Then Return True
                   Case 4
                       If y >= Value1.Value Then Return True
                   Case 5
                       If y <> Value1.Value Then Return True
               End Select
           Case 2
               Dim w As String = Trim(PrimeFactors(num))
               For x As Integer = 1 To w.Length - 1
                   If w.Substring(x, 1) = "(" Then
                       Dim y As Integer = 0
                       Do
                           y += 1
                       Loop Until w.Substring(x + y, 1) = "^"
                       Dim z As String = w.Substring(x + 1, y - 1)
                       Select Case Operator1.SelectedIndex
                           Case 0
                               If z < Value1.Value Then Return True
                           Case 1
                               If z > Value1.Value Then Return True
                           Case 2
                               If z = Value1.Value Then Return True
                           Case 3
                               If z <= Value1.Value Then Return True
                           Case 4
                               If z >= Value1.Value Then Return True
                           Case 5
                               If z <> Value1.Value Then Return True
                       End Select
                   End If
               Next
       End Select
       Return False

   End Function
   Function PrimeFactors(ByVal num As Long) As String
       'Take a number.
       'sort its factors.
       'Find prime factors
       'see how many times each prime factor goes into the number
       'return the formatted string with the answer
       PrimeFactors = ""
       Dim temp As New Number
       Dim prev As Long = 1
       temp.SetNum(num)
       Array.Sort(temp.Factors)
       For Each x As Long In temp.Factors
           If x <> prev Then
               Dim fac As New Number
               fac.SetNum(x)
               If fac.Prime = True Then
                   Dim y As Integer = 0
                   Dim z As Long = temp.Number
                   Do
                       y += 1
                       z = z / fac.Number
                   Loop Until (z = 1) Or (z / fac.Number <> Int(z / fac.Number))
                   PrimeFactors &= "(" & x & "^" & y & ") "
               End If
           End If
           prev = x
       Next
   End Function
End Class

Public Class Number
   Private _Number As Long
   Private _FSum As Long
   Private _FDif As Long
   Private _FPairs As Long
   Private _Type As String
   Private _Prime As Boolean
   Public Factors() As Long

   Property Number() As Long
       Get
           Return _Number
       End Get
       Set(ByVal Num As Long)
           _Number = Num
       End Set
   End Property
   ReadOnly Property FDif() As Long
       Get
           Return _FDif
       End Get
   End Property
   ReadOnly Property FSum() As Long
       Get
           Return _FSum
       End Get
   End Property
   Public Property Type() As String
       Get
           Return _Type
       End Get
       Set(ByVal Value As String)
           _Type = Value
       End Set
   End Property
   ReadOnly Property Prime() As Boolean
       Get
           Return _Prime
       End Get
   End Property
   ReadOnly Property FPairs() As Integer
       Get
           Return _FPairs
       End Get
   End Property
   Public Sub SetNum(ByVal Num As Long)
       _Number = Num
       For a As Integer = 1 To Int(Math.Sqrt(Num))
           If Num / a = Int(Num / a) Then
               If Factors Is Nothing Then
                   ReDim Factors(0)
               Else
                   ReDim Preserve Factors(Factors.Length)
               End If
               Factors(Factors.Length - 1) = a
               _FSum += a
               _FPairs += 1
               'If a > 1 Then 'And a <> Num / a Then
               ReDim Preserve Factors(Factors.Length)
               Factors(Factors.Length - 1) = Num / a
               _FSum += Num / a
               'End If
           End If
       Next
       _FSum -= Num

       'ReDim Preserve Factors(Factors.Length - 2)
       _FDif = _FSum - _Number

       If _Number > 1 And _FDif = 0 Then
           _Type = "Perfect"
       End If

       If _FPairs = 1 And _Number > 1 Then
           _Prime = True
       Else
           _Prime = False
       End If

   End Sub
   Public Sub RePopulate(ByVal Record As String)
       Dim c1, c2, f As Integer
       Dim temp As String
       Do
           c2 = Record.Substring(c1).IndexOf(",")
           temp = Record.Substring(c1, c2)
           Select Case f
               Case 0 ' number
                   _Number = temp
               Case 1 ' fsum
                   _FSum = temp
               Case 2 ' fdif
                   _FDif = temp
               Case 3 ' fpairs
                   _FPairs = temp
               Case 4 ' type
                   _Type = temp
               Case 5 ' prime
                   _Prime = temp
               Case Is >= 6 ' Each Factor
                   ReDim Preserve Factors(f - 6)
                   Factors(f - 6) = temp
           End Select
           f += 1
           c1 = c1 + c2 + 1
       Loop Until c1 + c2 >= Record.Length
   End Sub
End Class

You will want to use VB Express (free from MS) to debug.

 

Have fun! Let me know if you have any questions, or if you want files, I can send them too.

 

Bill

Posted

Wow Bill, you’ve gone the extra mile and then some. Absolutely freakin’ stellar.

 

I didn’t have a chance to run your program until just before writing this post. It’s obvious now there’s nothing I can do to improve the brute force search for strange number anomalies... and reading more of the thread before trying would definitely have tipped me off to that :)

 

I’ll keep playing catch-up, get a better lay of the land, and see if I have any insights.

 

~modest

Posted

I played with the code a bit last night because it upgraded from the 2003 vb.net to the 2005 vb.net when I opened it. (I really need to get the 2008 soon!) When it opened there were some warnings that the earlier IDE did not indicate, so I took some time to figure them out. I also played with how frequently the form refreshes and found that I could get the search rate up to 1000 to 2000 per second on my laptop, but it makes the application feel less responsive.

 

If I were going to do this again I would use threading to make the search a background function, but I have still not mastered having the background thread update the form which is owned by the main thread ?!?!

 

I cannot recall if I ever made any instructions for this. It took a little while for it to sink in again last night. I may do that one night this week. Especially if it will help people get some function out of it.

 

Bill

Posted
Since we are currently only after Strange anomalies, (i.e. numbers abundant by 12 that do not have 6 as a factor or they do have 6 as a factor but not paired with a prime.), then we ought to make a stripped down version too, and scout ahead.

 

Ok. That is just what the code I posted earlier does, but I'm afraid PERL is ridiculously slow at this kind of thing. I have a C compiler, but it's been a long time since I've touched C and I'm pretty limited for time at the moment. But, I do like the challenge and I haven't given up...

 

Should we guess where the next anomaly will be found, see who's closest :lol: My guess would be... ~900,000,000,000.

 

~modest

Posted

Ah-ha, trying to poach my super-secret guestimation techniques are ya? Well, I can’t give away the specifics (not for free :sherlock:), but I can tell you it involves an abacus, a human-sized centrifuge, a blind man (who may or may not need a parachute depending on how well the monkey can fly the plane), a C-17 cargo jet, 12 monkeys, 11 typewriters, and a 1910 map of Michigan.

 

~modest

Posted

I have some new tools at my disposal. I am thinking of making a new version of the Numberator that will use a database rather than text files. This will make loading the known data MUCH faster, and allow better analysis. I have some time coming to my hands so I will see if my inspiration finds some common ground with that.

 

Bill

Posted

:sherlock: :confused:

 

:edepress: and :evil: stuff going on here.

 

Have you considered numbers that are abundant by twice (or perhaps thrice)

a "3-perfect number", such as 120?

 

Could they, perhaps, also have similar properties?

 

Don.

Posted
OMG! I just now found an interesting pattern looking at our list and I now have a prediction for the next Strange Anomaly!!! :) :eek_big: :singer:

 

I give you, 2,199,009,624,064 or 220 * 2,097,139

 

I haven't factored it to check if it's Strange as I don't have software that will handle this large of a number. Little help here??? :turtle:

 

Hey T, sounds promising. I'm super-strapped for time so I'll just print the output I got. I haven't double checked it, so you should definitely check to see if it's correct—but, sorry, it doesn't look like it's abundant by 12 :turtle:

 

The factors are:

 

number = 2199009624064

1099504812032
2

549752406016
4

274876203008
8

199909965824
11

137438101504
16

99954982912
22

68719050752
32

49977491456
44

34359525376
64

24988745728
88

17179762688
128

12494372864
176

8589881344
256

6247186432
352

4294940672
512

3123593216
704

2147470336
1024

1561796608
1408

1073735168
2048

780898304
2816

536867584
4096

390449152
5632

268433792
8192

195224576
11264

134216896
16384

97612288
22528

67108448
32768

48806144
45056

33554224
65536

24403072
90112

16777112
131072

12201536
180224

11534336
190649

8388556
262144

6100768
360448

5767168
381298

4194278
524288

3050384
720896

2883584
762596

2097139
1048576

1525192
1441792

factor sum = 2598852433736
C:PerlStrangeNum>

 

Which sum to,

2598852433736

 

And,

number = 562949735317504

281474867658752
2

140737433829376
4

70368716914688
8

35184358457344
16

17592179228672
32

8796089614336
64

4398044807168
128

2857612869632
197

2199022403584
256

1428806434816
394

1099511201792
512

714403217408
788

549755600896
1024

357201608704
1576

274877800448
2048

178600804352
3152

137438900224
4096

89300402176
6304

68719450112
8192

44650201088
12608

34359725056
16384

22325100544
25216

17179862528
32768

11162550272
50432

8589931264
65536

5581275136
100864

4294965632
131072

3305111552
170327

2790637568
201728

2147482816
262144

1652555776
340654

1395318784
403456

1073741408
524288

826277888
681308

697659392
806912

536870704
1048576

413138944
1362616

348829696
1613824

268435352
2097152

206569472
2725232

174414848
3227648

134217676
4194304

103284736
5450464

87207424
6455296

67108838
8388608

51642368
10900928

43603712
12910592

33554419
16777216

25821184
21801856

 

Which sums to 568671571109360.

 

If you want me to check a range of numbers in the area of these, I can do that... but, I'm afraid PERL is really slow with numbers this big.

 

~modest

Posted

mr turtle, to answer your first question:

 

factors for 2199009624064 are:

1

2

4

8

11

16

22

32

44

64

88

128

176

256

352

512

704

1024

1408

2048

2816

4096

5632

8192

11264

16384

22528

32768

45056

65536

90112

131072

180224

190649

262144

360448

381298

524288

720896

762596

1048576

1441792

 

ok so the improved bc code for factoring is:

scale=0

print "nNumber to factor: "

num=read()
numiterations=num/2
prev=0

if ( num%10==1 || num%10==3 || num%10==5 || num%10==7 || num%10==9 )
{
numiterations=(num+1)/2
}
print "Factors: n"
for (i=1; i<=numiterations; i=i+1)
{
if ((num%i)==0)
{
if ((num/i)==prev)
{
break
}
i
prev=i
}
}
print "Done n"
quit

 

now i'm gonna run the 562,949,735,317,504 number (to doublecheck, and test the new code)

Posted

Number to factor: 562949735317504

Factors:

1

2

4

8

16

32

64

128

197

256

394

512

788

1024

1576

2048

3152

4096

6304

8192

12608

16384

25216

32768

50432

65536

100864

131072

170327

201728

262144

340654

403456

524288

681308

806912

1048576

1362616

1613824

2097152

2725232

3227648

4194304

5450464

6455296

8388608

10900928

12910592

16777216

21801856

 

actually, would you like it to be in a format more similar to modest's? (i'll change a couple of things in the code)

Posted

here's some better formatting code:

scale=0

print "nNumber to factor: "

num=read()
prev=0

if ( num%10==1 || num%10==3 || num%10==5 || num%10==7 || num%10==9 )
{
       numiterations=(num+1)/2
}
else
{
       numiterations=num/2
}

print "Factors: n"

for (i=1; i<=numiterations; i=i+1)
{
       if ((num%i)==0)
       {
               if ((num/i)==prev)
               {
               break
               }
       print i,"n",(num/i),"nn"
       prev=i
       }
}

print "Done n"

quit

 

mr turtle, you need cygwin, and GNU bc :phones:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...