/** * Ulam sequence. * * @author (Stefan Edelkamp) * @version (2013) */ public class Ulam { /** * The Ulam sequence * * @param n the number to start with * @return value 1 if reached */ public int u(int n) { System.out.print("u("+n+"),"); return n == 1 ? 1 : n%2 == 0 ? u(n/2) : u(3*n+1); } }