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

Home > Numbers
Primes and factors (Posted on 2017-03-17) Difficulty: 4 of 5
The first 2 consecutive whole numbers each having 2 distinct prime factors are 14=2×7 and 15=3×5.

The first 2 consecutive whole numbers each having 3 distinct prime factors are 230=2×5×23 and 231=3×7×11.

The first 3 consecutive whole numbers each having 3 distinct prime factors are 644=22×7×23, 645=3×5×43 and 646=2×17×19.

Find the first 3 consecutive whole numbers each having 5 distinct prime factors.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution carried beyond Comment 2 of 2 |
The third of the first set of three numbers in a row with 5 factors is 1,042,406.

1042404 = 2^2 * 3 * 11 * 53 * 149
1042405 = 5 * 7 * 13 * 29 * 79
1042406 = 2 * 17 * 23 * 31 * 43

5 fctrs 1 in row 2310
5 fctrs 2 in row 254541
5 fctrs 3 in row 1042406
5 fctrs 4 in row 21871368
5 fctrs 5 in row 129963318

Each result shows the last in the given size group, as that's when the count got to the given value. That last one represents

129963314 = 2 * 13 * 37 * 53 * 2549
129963315 = 3 * 5 * 31 * 269 * 1039
129963316 = 2^2 * 7 * 97 * 109 * 439
129963317 = 11^2 * 17 * 23 * 41 * 67
129963318 = 2 * 3 * 89 * 199 * 1223


having gotten up to n = 179756471, before manually terminating this program:

DefDbl A-Z
Dim crlf$, fct(20, 1)


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For n = 4 To 1000000000
   f = factor(n)

   If f >= 5 Then
     consec5 = consec5 + 1
   Else
     consec5 = 0
   End If
   

   If consec5 > con5max Then
     Text1.Text = Text1.Text & "5 fctrs " & consec5 & " in row " & n & crlf
     con5max = consec5
   End If
   DoEvents
Next n
 
 Text1.Text = Text1.Text & crlf & " done"
  
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

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
Function nxtprm(x)
  Dim n
  n = x + 1
  While prmdiv(n) < n
    n = n + 1
  Wend
  nxtprm = n
End Function



  Posted by Charlie on 2017-03-17 10:23:55
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 (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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