n differences: n minus each power of 2 below n (showing lowest prime factor and resulting quotient)
127 126(2*63), 125(5*25), 123(3*41), 119(7*17), 111(3*37), 95(5*19), 63(3*21)
149 148(2*74), 147(3*49), 145(5*29), 141(3*47), 133(7*19), 117(3*39), 85(5*17), 21(3*7)
251 250(2*125), 249(3*83), 247(13*19), 243(3*81), 235(5*47), 219(3*73), 187(11*17), 123(3*41)
331 330(2*165), 329(7*47), 327(3*109), 323(17*19), 315(3*105), 299(13*23), 267(3*89), 203(7*29), 75(3*25)
337 336(2*168), 335(5*67), 333(3*111), 329(7*47), 321(3*107), 305(5*61), 273(3*91), 209(11*19), 81(3*27)
373 372(2*186), 371(7*53), 369(3*123), 365(5*73), 357(3*119), 341(11*31), 309(3*103), 245(5*49), 117(3*39)
509 508(2*254), 507(3*169), 505(5*101), 501(3*167), 493(17*29), 477(3*159), 445(5*89), 381(3*127), 253(11*23)
599 598(2*299), 597(3*199), 595(5*119), 591(3*197), 583(11*53), 567(3*189), 535(5*107), 471(3*157), 343(7*49), 87(3*29)
701 700(2*350), 699(3*233), 697(17*41), 693(3*231), 685(5*137), 669(3*223), 637(7*91), 573(3*191), 445(5*89), 189(3*63)
757 756(2*378), 755(5*151), 753(3*251), 749(7*107), 741(3*247), 725(5*145), 693(3*231), 629(17*37), 501(3*167), 245(5*49)
809 808(2*404), 807(3*269), 805(5*161), 801(3*267), 793(13*61), 777(3*259), 745(5*149), 681(3*227), 553(7*79), 297(3*99)
877 876(2*438), 875(5*175), 873(3*291), 869(11*79), 861(3*287), 845(5*169), 813(3*271), 749(7*107), 621(3*207), 365(5*73)
905 904(2*452), 903(3*301), 901(17*53), 897(3*299), 889(7*127), 873(3*291), 841(29*29), 777(3*259), 649(11*59), 393(3*131)
907 906(2*453), 905(5*181), 903(3*301), 899(29*31), 891(3*297), 875(5*175), 843(3*281), 779(19*41), 651(3*217), 395(5*79)
959 958(2*479), 957(3*319), 955(5*191), 951(3*317), 943(23*41), 927(3*309), 895(5*179), 831(3*277), 703(19*37), 447(3*149)
977 976(2*488), 975(3*325), 973(7*139), 969(3*323), 961(31*31), 945(3*315), 913(11*83), 849(3*283), 721(7*103), 465(3*155)
997 996(2*498), 995(5*199), 993(3*331), 989(23*43), 981(3*327), 965(5*193), 933(3*311), 869(11*79), 741(3*247), 485(5*97)
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For n = 3 To 1000 Step 2
pwr2 = 1
found = 0
Do
p = n - pwr2
If prmdiv(p) = p And p <> 1 Then
found = 1
Exit Do
End If
pwr2 = 2 * pwr2
Loop Until pwr2 >= n
If found = 0 Then
Text1.Text = Text1.Text & n & " "
pwr2 = 1
Do
p = n - pwr2
Text1.Text = Text1.Text & Str(p) & "("
Text1.Text = Text1.Text & prmdiv(p)
p = p / prmdiv(p)
Text1.Text = Text1.Text & "*" & p
Text1.Text = Text1.Text & ")"
pwr2 = 2 * pwr2
If pwr2 < n Then Text1.Text = Text1.Text & ","
Loop Until pwr2 >= n
Text1.Text = Text1.Text & crlf
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function prmdiv(num)
Dim n, dv, q
If num = 1 Then prmdiv = 1: Exit Function
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
Loop
If n > 1 Then prmdiv = n
Exit Function
DivideIt:
Do
q = Int(n / dv)
If q * dv = n And n > 0 Then
prmdiv = dv: Exit Function
Else
Exit Do
End If
Loop
Return
End Function
|
Posted by Charlie
on 2016-07-06 10:12:59 |