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

 Primevens and primeodds (Posted on 2016-01-10)
Let a primeven be a positive integer that is the product of an even number of primes. Let a primeodd be a positive integer that is the product of an odd number of primes. Then, 1 is a primeven because it is the product of 0 primes. 2 is a primeodd because it is the product of 1 prime. 3 is a primeodd because it is the product of 1 prime. 4 is a primeven because it is the product of 2 primes. Here are the first 10 positive integers.
```Number:   Factorization:      Number of primes:   Type:
1                             0                   primeven
2         2                   1                   primeodd
3         3                   1                   primeodd
4         2*2                 2                   primeven
5         5                   1                   primeodd
6         2*3                 2                   primeven
7         7                   1                   primeodd
8         2*2*2               3                   primeodd
9         3*3                 2                   primeven
10        2*5                 2                   primeven
```
Suppose the primevens and primeodds had a race. First, the primevens would be ahead because 1 is a primeven. Then, there would be a tie because 2 is a primeodd. Then, the primeodds would be ahead because 3 is a primeodd. Then, there would be a tie because 4 is a primeven. Here are the winners from 1 to 10.
```Number:   Type:          Primevens:     Primeodds:     Winner:
1         primeven       1              0              primevens
2         primeodd       1              1              tie
3         primeodd       1              2              primeodds
4         primeven       2              2              tie
5         primeodd       2              3              primeodds
6         primeven       3              3              tie
7         primeodd       3              4              primeodds
8         primeodd       3              5              primeodds
9         primeven       4              5              primeodds
10        primeven       5              5              tie
```
The primevens were ahead at the start, but have not been ahead since then. Do the primevens ever become the winner again?

 No Solution Yet Submitted by Math Man Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 some stats | Comment 2 of 8 |
In the first 10 million numbers, 1 is the only case where it happens.  However the numbers are close enough to mimic a random walk (difference is within the square root of the total).

1 1 0***

then totals shown every million:

`   max     evens   odds  number 1000000   499735  500265 2000000   999383 1000617 3000000  1499529 1500471 4000000  1999451 2000549 5000000  2498854 2501146 6000000  2999254 3000746 7000000  3499209 3500791 8000000  3998778 4001222 9000000  4498714 450128610000000  4999579 5000421`

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

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For i = 1 To 10000000
DoEvents
f = factor(i)
pf = 0
For j = 1 To f
pf = pf + fct(j, 1)
Next
If pf Mod 2 = 0 Then evenct = evenct + 1 Else oddct = oddct + 1
If i Mod 1000000 = 0 Then
Text1.Text = Text1.Text & i & Str(evenct) & Str(oddct) & crlf
End If
If evenct > oddct Then
Text1.Text = Text1.Text & i & Str(evenct) & Str(oddct) & "***" & crlf
End If
Next

Text1.Text = Text1.Text & crlf & " done"

End Sub

Function factor(num)
diffCt = 0: good = 1
nm1 = Abs(num): If nm1 > 0 Then limit = Sqr(nm1) 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 nm1 > 1 Then diffCt = diffCt + 1: fct(diffCt, 0) = nm1: fct(diffCt, 1) = 1
factor = diffCt
Exit Function

DivideIt:
cnt = 0
Do
q = Int(nm1 / dv)
If q * dv = nm1 And nm1 > 0 Then
nm1 = q: cnt = cnt + 1: If nm1 > 0 Then limit = Sqr(nm1) 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 2016-01-10 14:12:52

 Search: Search body:
Forums (4)