Skip to content

Instantly share code, notes, and snippets.

@fermopili
Created March 19, 2017 12:48
Show Gist options
  • Save fermopili/39cfbf8213c60d54056f72f270071e3d to your computer and use it in GitHub Desktop.
Save fermopili/39cfbf8213c60d54056f72f270071e3d to your computer and use it in GitHub Desktop.
com.javarush.task.task14.task1420
/*
простенький НОД
*/
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