This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const euler_15 = n => nCr(2*n,n); | |
const nCr = (n,r) => { | |
if (r > n || n < 1 || r < 1) { | |
return undefined; | |
} | |
return factorial(n) / (factorial(r) * factorial(n-r)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import time | |
import math | |
parser = argparse.ArgumentParser(description = 'Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.\n\nHow many such routes are there through a nxn grid?') | |
parser.add_argument('--num', default = 20, type = int, help = 'Insert the number here, it must be a positive integer. It defaults to 20 to correspond with the Project Euler Problem at https://projecteuler.net/problem=15') | |
x = parser.parse_args().num | |
timing = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello from Python! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello from Python! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello from Python! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int euler_1(int n); | |
int main() { | |
int n; | |
scanf("Please enter a number here: %d",&n); | |
printf("Here is your answer: %d\n",euler_1(n)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const euler_1 = n => { | |
let result = 0, | |
x = n/3, | |
y = n/5 | |
for (let i = 1; i < x; i++) { | |
result += i*3; | |
} | |
for (let i = 1; i < x; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import sys | |
sys.path.append('/home/gavin/Documents/Git Repositories/project-euler') | |
import pyfuncs | |
challenge = 'Find the sum of all the multiples of 3 or 5 below {}:' | |
parser = argparse.ArgumentParser(description = 'Find the sum of all the multiples of 3 or 5 below a given number.') | |
parser.add_argument('--num', default = 1000, type = int, help = 'Insert the number here, it must be a positive integer. It defaults to 1000 to correspond with the Project Euler Problem at https://projecteuler.net/problem=1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
fn main() { | |
let args: Vec<String> = env::args().collect(); | |
let val: i32 = args[0].parse().unwrap(); | |
println!("Answer: {}",euler_1(val)); | |
} | |
fn euler_1(x: i32) -> i32 { | |
let mut result: i32 = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. | |
O,E,O,O,E,O,O,E,O,O, | |
A number in the Fibonacci sequence can only be even if its 2 preceding terms are either both even or both odd, as it turns out, every 3rd term is even. | |
As it also turns out, there isn't really a whole lot I can do with this information. | |
*/ | |
const euler_2 = n => { | |
let result = 0, |