Created
November 20, 2020 15:14
-
-
Save AngelOnFira/a92328c71d8024d9c4a61df1f4f2f93f to your computer and use it in GitHub Desktop.
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
| pub fn gcd(numbers: Vec<i32>) -> i32 { | |
| let mut lcd = *numbers.iter().max().unwrap(); | |
| for i in 0..(numbers.len()) { | |
| let mut x: i32 = lcd; | |
| let mut y: i32 = numbers[i]; | |
| lcd = { | |
| while y != 0 { | |
| let temp = x % y; | |
| x = y; | |
| y = temp; | |
| } | |
| x | |
| } | |
| } | |
| lcd | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment