Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Gray-code/PARI-GP/gray-code.parigp
Normal file
5
Task/Gray-code/PARI-GP/gray-code.parigp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
toGray(n)=bitxor(n,n>>1);
|
||||
fromGray(n)=my(k=1,m=n);while(m>>k,n=bitxor(n,n>>k);k+=k);n;
|
||||
bin(n)=concat(apply(k->Str(k),binary(n)))
|
||||
|
||||
for(n=0,31,print(n"\t"bin(n)"\t"bin(g=toGray(n))"\t"fromGray(g)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue