Skip to content

Commit

Permalink
Add solution for problem 3
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 12, 2024
1 parent 5b93ce0 commit e5b8934
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
18 changes: 18 additions & 0 deletions docs/rust/p0003.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Rust Implementation of Problem 3
================================

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/rust/src/p0003.rs>`_

Includes
--------

- `primes <./primes.html>`_

Problem Solution
----------------

.. rust:fn:: p0003::p0003() -> u64
.. literalinclude:: ../../rust/src/p0003.rs
:language: rust
:linenos:
6 changes: 3 additions & 3 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ use rstest::rstest;
#[cfg(test)]
use itertools::Itertools;

seq!(N in 0001..=0002 {
seq!(N in 0001..=0003 {
mod p~N;
});
mod primes;

type ProblemType = fn() -> u64;
type ProblemRef<'a> = (&'a str, ProblemType, u64);
const ANSWERS: [ProblemRef; 2] = [
const ANSWERS: [ProblemRef; 3] = [
("p0001", p0001::p0001, 233168),
("p0002", p0002::p0002, 4613732),
// ("p0003", p0003::p0003, 6857),
("p0003", p0003::p0003, 6857),
];

fn main() {
Expand Down
16 changes: 16 additions & 0 deletions rust/src/p0003.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Project Euler Problem 3
This problem was fun, because it let me learn how to make Iterators in rust
Problem:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*/
mod primes;

pub fn p0003() -> u64 {
return primes::prime_factors(600851475143).max();
}

0 comments on commit e5b8934

Please sign in to comment.