Current work thus far
Changes to be committed: new file: 079PassDerive.py new file: 085CountTriangle.py new file: 101TriangleContain.py new file: 102_triangles.py new file: 112_bouncy.py new file: 187_semiprime/187_semiprime new file: 187_semiprime/primes.txt new file: 187_semiprime/semiprime.go new file: 493Rainbow.py new file: codedTriangle.py new file: coinSum.py new file: eulerCoinSum.py new file: fiboChecker.py new file: oddEven.py new file: p042_words.txt new file: powerfulDigit.py new file: selfPower.py new file: sunday.py new file: symbolCheck.py
This commit is contained in:
BIN
187_semiprime/187_semiprime
Executable file
BIN
187_semiprime/187_semiprime
Executable file
Binary file not shown.
40
187_semiprime/primes.txt
Normal file
40
187_semiprime/primes.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
104777
|
||||
224777
|
||||
350430
|
||||
479958
|
||||
611986
|
||||
746796
|
||||
882407
|
||||
1020421
|
||||
1159557
|
||||
1299762
|
||||
1441080
|
||||
1583615
|
||||
1726977
|
||||
1870727
|
||||
2015226
|
||||
2160606
|
||||
2307264
|
||||
2454646
|
||||
2601918
|
||||
2750198
|
||||
2898575
|
||||
3047798
|
||||
3196971
|
||||
3346657
|
||||
3497892
|
||||
3648972
|
||||
3800242
|
||||
3951203
|
||||
4103663
|
||||
4256273
|
||||
4410366
|
||||
4562748
|
||||
4716106
|
||||
4869917
|
||||
5023360
|
||||
5178092
|
||||
5332561
|
||||
5487779
|
||||
5644074
|
||||
5800173
|
||||
56
187_semiprime/semiprime.go
Normal file
56
187_semiprime/semiprime.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
THREADCOUNT := 20
|
||||
primeList:=make([]int,0,4000)
|
||||
sentCount:=0
|
||||
recvCount:=0
|
||||
chani := make(chan int)
|
||||
var tempi int
|
||||
|
||||
for i:=2; i<50000000; i++ {
|
||||
if sentCount - recvCount < THREADCOUNT {
|
||||
sentCount+=1
|
||||
go checkPrime(i, chani)
|
||||
} else {
|
||||
emptyChannel := false
|
||||
for emptyChannel!= true {
|
||||
select {
|
||||
case tempi = <-chani:
|
||||
recvCount+=1
|
||||
if tempi!=0 {
|
||||
primeList=append(primeList, tempi)
|
||||
if len(primeList) % 10000 ==0 {
|
||||
fmt.Println(i)
|
||||
}
|
||||
}
|
||||
default:
|
||||
emptyChannel = true
|
||||
}
|
||||
}
|
||||
i-= 1
|
||||
}
|
||||
}
|
||||
fmt.Println(primeList)
|
||||
}
|
||||
|
||||
|
||||
func checkPrime(i int, chani chan int) bool {
|
||||
checkCount := 0
|
||||
|
||||
for c:=2; c<i/2; c++ {
|
||||
if i%c == 0 {
|
||||
checkCount+=1
|
||||
break
|
||||
}
|
||||
}
|
||||
if checkCount==0 {
|
||||
chani <- i
|
||||
return true
|
||||
} else {
|
||||
chani <- 0
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user