Gray code by uru

class _{public static void main(String[]x)throws Exception{int n,i=0;for(System.out.printf("Gray code  n=%d\n",n=System.in.read()-48);i<1<<n;System.out.println(Long.toString(128+i^i++/2,2).substring(8-n)));}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page