We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c598b58 + f75ad03 commit 1ced9c5Copy full SHA for 1ced9c5
src/hackerrank/projecteuler/euler003.ts
@@ -11,24 +11,18 @@ export function primeFactor(n: bigint): bigint {
11
12
let divisor: bigint = n;
13
let maxPrimeFactor: bigint = divisor;
14
- let mpfInitialized = false;
15
16
let i = 2n;
17
18
while (i <= BigIntMath.sqrt(divisor)) {
19
if (divisor % i === 0n) {
20
divisor /= i;
21
maxPrimeFactor = divisor;
22
- mpfInitialized = true;
23
} else {
24
i += 1n;
25
}
26
27
28
- if (!mpfInitialized) {
29
- return n;
30
- }
31
-
32
return maxPrimeFactor;
33
34
0 commit comments