Gray code by Patashu (looked it up)

class F{public static void main(String[]_)throws Exception{int i=0,n=System.in.read()%8;System.out.println("Gray code  n="+n);for(;i<Math.pow(2,n);System.out.format("%0"+n+"d\n",Long.valueOf(Long.toString(i^i++/2,2))));}}

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

download

return to the top page