Created
March 19, 2017 12:48
-
-
Save fermopili/39cfbf8213c60d54056f72f270071e3d to your computer and use it in GitHub Desktop.
com.javarush.task.task14.task1420
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
/* | |
простенький НОД | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
int v1 = Integer.parseInt(reader.readLine()); | |
if (v1 <= 0) throw new NumberFormatException(); | |
int v2 = Integer.parseInt(reader.readLine()); | |
if (v2 <= 0) throw new NumberFormatException(); | |
while (v2 != 0) | |
{ | |
int tmp = v1 % v2; | |
v1 = v2; | |
v2 = tmp; | |
} | |
System.out.println(v1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment