import java.util.*; public class GcdDemo{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Enter 2 marks: "); int n1=sc.nextInt(); int n2=sc.nextInt(); int res=gcd(n1,n2); System.out.println("GCD is: "+res); } private static int gcd(int a,int b){ if(n2==0) return n1; return(gcd(n2,n1%n2)) } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter