-
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.
solve p7 in lua, fix p3. primes() is too slow
- Loading branch information
1 parent
70b7ddd
commit 5260a85
Showing
7 changed files
with
113 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Lua Implementation of Problem 7 | ||
=============================== | ||
|
||
View source code :source:`lua/src/p0007.lua` | ||
|
||
Includes | ||
-------- | ||
|
||
- `primes.lua <./lib/primes.html>`__ | ||
|
||
Solution | ||
-------- | ||
|
||
.. lua:function:: solution() | ||
:return: The solution to problem 7 | ||
:rtype: number | ||
|
||
.. literalinclude:: ../../../lua/src/p0007.lua | ||
:language: Lua | ||
:linenos: | ||
|
||
.. tags:: factorization, prime-number, lua-iterator |
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,22 @@ | ||
-- Project Euler Problem 7 | ||
-- | ||
-- Problem: | ||
-- | ||
|
||
local primes = loadlib("primes").primes | ||
|
||
return { | ||
solution = function() | ||
local idx = 0 | ||
local num = 0 | ||
local pgen = primes() | ||
|
||
repeat | ||
idx = idx + 1 | ||
num = pgen.next() | ||
print(idx .. ", " .. num) | ||
until idx > 10000 | ||
|
||
return num | ||
end | ||
} |
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