- 0
Notifications Mark All Read
- Login
- Get Prime
Cognizant Coding Question- 6
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
Notifications Mark All Read
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
You can Try this Way :
import java.util.*;
public class GCD {
public static void main(String args[])
{
int a,b;
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();
int n=Math.min(a, b);
for(int i=n;i>=1;i–)
{
if(a%i==0&&b%i==0)
{
System.out.println(i);
break;
}
}
}
}