Skip to content

Instantly share code, notes, and snippets.

@lounestor
lounestor / CommonDenominator.java
Created November 25, 2012 17:11
determining Greatest Common Divisor and Lowest Common Multiple
public class CommonDenominator {
public static void main(String[] args) {
System.out.println(GCD(64,40)+"...................");
System.out.println(LCM(24, 60));
}
public static int GCD(int a, int b) {
@lounestor
lounestor / countwords.java
Created November 23, 2012 17:12
Count the words in a sentence
public static List wordCount(String fileName) {
List list = new ArrayList();
String input = fileName;
int words = 0;
int totalchar = 0;
int lines = 0;
int longestWord = 0;
int shortestWord = 99999;
try{
//System.out.println("Reading from file: " + input);
@lounestor
lounestor / PrimeNumbers.java
Created November 22, 2012 00:13
Getting Prime Numbers
public class PrimeNumber {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//specific prime and nonprime numbers in range
for (long i=1; i<50; ++i){