Skip to content

Commit a9bfdc6

Browse files
committed
204
1 parent a4e4bde commit a9bfdc6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

204/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
func countPrimes(n int) int {
2+
notPrimes := make([]bool, n)
3+
count := 0
4+
for i := 2; i < n; i++ {
5+
if notPrimes[i] == false {
6+
count++
7+
for j := 2; i*j < n; j++ {
8+
notPrimes[i*j] = true
9+
}
10+
}
11+
}
12+
return count
13+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
- [198 House Robber](./198)
114114
- [199 Binary Tree Right Side View](./199)
115115
- [200 Number of Islands](./200)
116+
- [204 Count Primes](./204)
116117
- [206 Reverse Linked List](./206)
117118
- [207 Course Schedule](./207)
118119
- [208 Implement Trie (Prefix Tree)](./208)

0 commit comments

Comments
 (0)