Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-euler

Build Status

Easily download problems from project euler and generate an empty solution program for each. Some common functions are provided, e.g. prime factorization.

Run $ cargo run to download the problems into the examples directory

The empty solution program is based on examples/solution_templates.rs and looks something like this:

/*
[https://projecteuler.net/problem=3]

Largest prime factor

The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143
?
*/

fn solution() -> u64 {
    42
}

fn main() {
    println!("{}", solution());
}

You can run the solution like this: $cargo run --example p001

The library for common functions is called euler as defined in Cargo.toml. You can add extend it by adding your code to src/lib.rs. These functions can be used like you would any other library:

use euler::prime::factors;

for f in prime_factors(12345) {
    println!("{}", factor);
}

About

Fetch problems from Project Euler and create an empty solution program for each

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages