/* ESC101 : Fundamental of Computing Lab 6 for 10th September 2008 Two numbers a and b are said to be relatively prime ( also called coprime) if gcd(a; b) = 1. For a given n write a JAVA program to nd the number of coprimes less than n. For example, if n = 9, then the output should be 6 since the coprimes of 9 less than 9 are 1; 2; 4; 5; 7 and 8. You should design and use a method called gcd which takes two integer arguments and returns their gcd. */ class RelPrime { //Method to calculate GCD of two numbers. public static int gcd(int a, int b) { int t; while(b != 0){ t = b; b = a % b; a = t; } return a; } public static void main(String args[]) { int n; int gcd; int i,prime_cnt = 0; if(args.length==0) System.out.println("Please give a numeric arguement as a command line..."); else { n = Integer.parseInt(args[0]); for(i=1;i