Revision 4d5be7c4-45b4-44c7-827b-31d911c68214 - Stack Overflow
##Java, <strike>200</strike> <strike>192</strike> 179 characters
I think everyone knows that Java would not have the shortest implementation, but I wanted to see how it would compare. It solves the trivial examples, but not the bonus one.
Here is the minimized version:
class F{public static void main(String[]a){long p=new Long(a[0]);for(int i=1;i<a.length;){long n=p*new Long(a[i++]),d=new Long(a[i++]);if(n%d<1){p=n/d;i=1;}}System.out.print(p);}}
java -cp . F 108 455 33 11 13 1 11 3 7 11 2 1 3
15625
java -cp . F 1296 3 2
6561
Here is the cleaned-up version:
public class Fractran {
public static void main(String[] args) {
long product = new Long(args[0]);
for (int index = 1; index < args.length;) {
long numerator = product * new Long(args[index++]);
long denominator = new Long(args[index++]);
if (numerator % denominator < 1) {
product = numerator / denominator;
index = 1;
} // if
} // for
System.out.print(product);
}
}