diff --git a/SCMethod1.java b/SCMethod1.java index 6f06901..3c19b2d 100644 --- a/SCMethod1.java +++ b/SCMethod1.java @@ -1,18 +1,14 @@ package scmethod1; public class SCMethod1 -{ - - int gcd(int m,int n) - { - while(m!=n) - { - if(m>n)m=m-n; - else n=n-m; - } - return m; - } - +{ + int gcd(int a, int b) + { + if (a == 0) + return b; + return gcd(b % a, a); + } + public static void main(String[] args) { SCMethod1 x=new SCMethod1(); @@ -26,7 +22,7 @@ public static void main(String[] args) static boolean isPrime(int n) { - for(int i=2;i