-
-
Notifications
You must be signed in to change notification settings - Fork 360
Minor changes to euclidean algorithm implementation in Common Lisp #609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
berquist
merged 17 commits into
algorithm-archivists:master
from
Trashtalk217:euclidean-changes-lisp
Sep 9, 2019
Merged
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7b5c628
Added a proof for the Euclidean Algorithm
Trashtalk217 131ae54
Revert "Added a proof for the Euclidean Algorithm"
Trashtalk217 74d7f61
Added docstrings and changed some code for brevity
Trashtalk217 5c4dc6b
Slightly changed the .md file to fit the changes.
Trashtalk217 2909c78
Changed the filename to be shorter
Trashtalk217 44e5523
Fixed the namechange to work
Trashtalk217 6612af5
Revert "Fixed the namechange to work"
Trashtalk217 7ed7602
Fixed the namechange to work again
Trashtalk217 cbe7585
update
Trashtalk217 58efad6
Changed indentations
Trashtalk217 ca7c648
changed a comment
Trashtalk217 db00304
Added newline at the end
Trashtalk217 4237b88
update
Trashtalk217 e1953bb
changed the euclid-sub function and fixed issues
Trashtalk217 a4cb76c
fixed indentation, and changed .md file
Trashtalk217 8e07794
update
Trashtalk217 329f333
update
Trashtalk217 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,31 @@ | ||
;;;; Euclid algorithm implementation in Common Lisp | ||
|
||
(defun euclid-sub (a b) | ||
"Finds the greatest common divsor for any two integers" | ||
(euclid-sub* (abs a) (abs b))) | ||
|
||
(defun euclid-sub* (a b) | ||
"Finds the greatest common divisor for any two positive integers" | ||
(if (eq a b) | ||
a | ||
(if (> a b) | ||
(euclid-sub* (- a b) b) | ||
(euclid-sub* a (- b a))))) | ||
|
||
(defun euclid-mod (a b) | ||
"Finds the greatest common divisor for any two integers" | ||
(if (zerop b) | ||
(abs a) | ||
(euclid-mod b (mod a b)))) | ||
|
||
(print (euclid-sub (* 64 67) (* 64 81))) | ||
(print (euclid-mod (* 128 12) (* 128 77))) | ||
|
||
; quick test | ||
(assert | ||
(= (euclid-sub (* 64 67) (* 64 81)) | ||
(gcd (* 64 67) (* 64 81)))) | ||
|
||
(assert | ||
(= (euclid-mod (* 64 67) (* 64 81)) | ||
(gcd (* 64 67) (* 64 81)))) |
33 changes: 0 additions & 33 deletions
33
contents/euclidean_algorithm/code/clisp/euclidean_algorithm.lisp
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.