mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
p27
This commit is contained in:
37
inputs/passing/projEuler/p27.ts
Normal file
37
inputs/passing/projEuler/p27.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
//! test_output_slow(-59231)
|
||||
|
||||
import { isPrime } from "./helpers/primes.ts";
|
||||
|
||||
export default function main() {
|
||||
let best = {
|
||||
a: 0,
|
||||
b: 0,
|
||||
n: 0,
|
||||
};
|
||||
|
||||
for (let a = -999; a < 1000; a++) {
|
||||
for (let b = -999; b < 1000; b++) {
|
||||
let n = 0;
|
||||
|
||||
while (true) {
|
||||
const p = n * n + a * n + b;
|
||||
|
||||
if (p < 2) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isPrime(p)) {
|
||||
break;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
if (n > best.n) {
|
||||
best = { a, b, n };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best.a * best.b;
|
||||
}
|
||||
Reference in New Issue
Block a user