Legendre prime counting function: Difference between revisions

m
Swift: Add missing extension
m (cleanup swift)
m (Swift: Add missing extension)
Line 768:
 
<lang swift>import Foundation
 
extension Numeric where Self: Strideable {
@inlinable
public func power(_ n: Self) -> Self {
return stride(from: 0, to: n, by: 1).lazy.map({_ in self }).reduce(1, *)
}
}
 
func eratosthenes(limit: Int) -> [Int] {
Line 834 ⟶ 841:
 
for i in 0..<10 {
let n = 10.powpower(i)
 
print("π(10^\(i)) = \(π(n: n))")