Skip to content

Instantly share code, notes, and snippets.

View omeiza's full-sized avatar

Omeiza Owuda omeiza

View GitHub Profile
@omeiza
omeiza / largest-palindrome-product.js
Created September 21, 2021 23:32
Project Euler Larget Palindrome Product
// A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
// Find the largest palindrome made from the product of two 3-digit numbers.
function isPalindrome(num) {
const numStr = num.toString(),
numStrLength = numStr.length;
// Loop
for (let i = 0; i < numStrLength / 2; i++) {
if (numStr[i] != numStr[numStrLength - 1 - i]) {
@omeiza
omeiza / largest-prime-factor.js
Created September 21, 2021 23:29
Project Euler Largest prime Factor
// The prime factors of 13195 are 5, 7, 13 and 29.
// What is the largest prime factor of the number 600851475143?
// Define prime factors: Well, they are factors of a number that are prime. i.e prime are numbers that are divisible by 1 and itself
// Solution
const primeFactorOps = {};
primeFactorOps.cache = [];
@omeiza
omeiza / fibonacci-add-even.js
Last active September 21, 2021 23:21
Project Euler Sum of even valued fibonacci sequence
// Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
// By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
function fiboAddEven(start, limit) {
if ((typeof start !== "number" || start === 0) || typeof limit !== "number") return "Arguments supplied to fn fiboEvenAdd must be a natural integer";
let fibArray = [];
fibArray.push(start);
@omeiza
omeiza / multiple-3-5.js
Last active November 25, 2021 01:55
Project Euler Multiples of 3 and 5 Solution
// Problem: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
// The sum of these multiples is 23.
// Find the sum of all the multiples of 3 or 5 below 1000.
// Solution:
function getSumOfMultiples(limit) {
// confirm limit is a number
if (typeof limit !== "number") return "The parameter supplied for fn getSumOfMultiples must be a valid number";