1 
2 #include "bits/negbin.h"
3 
4 #include "fxttypes.h"  // ulong
5 
6 #include "fxtio.h"
7 #include "nextarg.h"
8 
9 //% OEIS sequence A005351:
10 //% Base -2 representation for n reinterpreted as binary.
11 //% Also sequence A005352:
12 //% Base -2 representation of -n reinterpreted as binary.
13 
14 // Cf. seq/A039724-demo.cc
15 // Cf. seq/A007608-demo.cc
16 
17 
18 int
main(int argc,char ** argv)19 main(int argc, char **argv)
20 {
21     ulong n = 66;
22     NXARG(n, "Convert numbers 0,1,2,...,n");
23     bool nq = false;
24     NXARG(nq, "Whether to convert numbers 0,-1,-2,...,-n");  // A005352
25 
26     for (ulong s=0; s<=n; ++s)
27     {
28         const ulong k = ( nq ? -s : +s );
29         ulong x = bin2neg(k);
30 
31         cout << x << ", ";
32 //        cout << s << " " << x << endl;  // b-file
33     }
34     cout << endl;
35 
36     return 0;
37 }
38 // -------------------------
39 
40 
41 /// Emacs:
42 /// Local Variables:
43 /// MyRelDir: "demo/seq"
44 /// makefile-dir: "../../"
45 /// make-target: "1demo DSRC=demo/seq/A005351-demo.cc"
46 /// make-target2: "1demo DSRC=demo/seq/A005351-demo.cc DEMOFLAGS=-DTIMING"
47 /// End:
48