-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEquations.swift
More file actions
46 lines (42 loc) · 792 Bytes
/
Equations.swift
File metadata and controls
46 lines (42 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Foundation
class calculation {
var prime = [Int](repeating: 0, count: 1000006)
let n: Int
var ans = 1
init(n: Int) {
self.n = n
}
func sieve() {
var p = 2
while p * p <= 1000000 {
if prime[p] == 0 {
var i = p * 2
while i <= 1000000 {
prime[i] = 1
i += p
}
}
p += 1
}
}
func factors() {
for i in 2...n {
if prime[i] == 0 {
var pp = 1
var cnt = 0
var x = Int(pow(Double(i),Double(pp)))
while x <= n {
cnt = cnt + (n / (Int(pow(Double(i),Double(pp)))))
pp += 1
x = Int(pow(Double(i),Double(pp)))
}
ans = (ans * (2 * cnt + 1)) % 1000007
}
}
}
}
let n = Int(readLine()!)!
let obj = calculation(n: n)
obj.sieve()
obj.factors()
print(obj.ans)