Euler 1-5

This commit is contained in:
Jos van Goor 2022-12-01 16:45:37 +01:00
parent 9cf858b860
commit 68a75987e2
6 changed files with 161 additions and 0 deletions

16
project_euler/problem3.cc Normal file
View file

@ -0,0 +1,16 @@
#include <cstdint>
#include <fmt/format.h>
#include "sieve.h"
int main()
{
std::uint64_t input = 600'851'475'143;
auto sieve = std::make_unique<Sieve<1'000'000>>();
for (auto value = static_cast<std::uint64_t>(std::sqrt(input)); value--; )
{
if (sieve->is_prime(value) && input % value == 0)
fmt::print("Result: {}\n", value);
}
}