-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2178244
commit 56c5203
Showing
9 changed files
with
121 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Project Euler Problem 3 | ||
More lazy functions this time. | ||
Problem: | ||
The prime factors of 13195 are 5, 7, 13 and 29. | ||
What is the largest prime factor of the number 600851475143 ? | ||
*/ | ||
|
||
#ifndef EULER_P0003 | ||
#define EULER_P0003 | ||
#include <stdint.h> | ||
#include <iostream> | ||
#include "include/macros.hpp" | ||
|
||
uint16_t EMSCRIPTEN_KEEPALIVE p0003() { | ||
uint16_t answer = 0; | ||
pfs = new PrimeFactors(600851475143); | ||
while (pfs.has_next()) | ||
answer = next(pfs); | ||
return answer; | ||
} | ||
|
||
|
||
PROGRAM_TAIL(p0003) | ||
#endif |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,7 @@ | |
|
||
answers = { | ||
x: get_answer(x) for x in ( | ||
1, | ||
2, | ||
4, | ||
*range(1, 5), | ||
*range(6, 10), | ||
11, | ||
*range(13, 18), | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
C++ Implementation of Problem 3 | ||
=============================== | ||
|
||
View source code :source:`cplusplus/src/p0003.cpp` | ||
|
||
Includes | ||
-------- | ||
|
||
- `"primes.hpp" <./lib/primes.html>`__ | ||
- :external:c:type:`stdint` | ||
- :external:cpp:type:`iostream` | ||
|
||
Solution | ||
-------- | ||
|
||
.. cpp:namespace-push:: p0003 | ||
|
||
.. cpp:function:: uint16_t p0003() | ||
|
||
.. cpp:function:: int main(int argc, char const *argv[]) | ||
|
||
.. note:: | ||
|
||
This function is only present in the Python test runner, or when compiling as a standalone program. | ||
|
||
.. literalinclude:: ../../../cplusplus/src/p0003.cpp | ||
:language: C++ | ||
:linenos: | ||
|
||
.. tags:: fibonacci-number, divisibility |