Compare commits
4 Commits
javascript
...
master
Author | SHA1 | Date | |
---|---|---|---|
e915d72b0d
|
|||
674702bac4 | |||
424a335253 | |||
b9646efea6 |
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 h7x4 <h7x4@nani.wtf>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Project Euler
|
||||
|
||||
This is a private repository for solutions to the [Project Euler](https://projecteuler.net/) excersizes.
|
||||
|
||||
Switch branch to find solutions written in different languages.
|
@ -1,29 +0,0 @@
|
||||
const MAX_LIMIT = 4000000
|
||||
|
||||
function fibonacci(index) {
|
||||
if (index === 0) return 0;
|
||||
|
||||
let A = 0;
|
||||
let B = 1;
|
||||
|
||||
for (let i = 0; i < (index - 1); i++) {
|
||||
let C = A + B;
|
||||
A = B;
|
||||
B = C;
|
||||
}
|
||||
|
||||
return B;
|
||||
}
|
||||
|
||||
let sum = 0;
|
||||
let currentNum = 0;
|
||||
let i = 0;
|
||||
while (currentNum < MAX_LIMIT) {
|
||||
currentNum = fibonacci(i);
|
||||
if (currentNum % 2 === 0) {
|
||||
sum += currentNum;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
console.log(sum);
|
@ -1,20 +0,0 @@
|
||||
function primeFactorsOf(n) {
|
||||
let k = 2;
|
||||
let factors = [];
|
||||
|
||||
while (n >= k**2) {
|
||||
if (n % k === 0) {
|
||||
factors.push(k)
|
||||
n = n/k;
|
||||
} else {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
factors.push(n);
|
||||
return factors;
|
||||
}
|
||||
|
||||
const SPECIAL_NUM = 600851475143;
|
||||
const factorsOfSpecialNum = primeFactorsOf(SPECIAL_NUM);
|
||||
|
||||
console.log(Math.max.apply(null, factorsOfSpecialNum));
|
Reference in New Issue
Block a user