Zeckendorf number representation: Difference between revisions
→{{header|Quackery}}: bit twiddling
Not a robot (talk | contribs) (Add Cowgol) |
(→{{header|Quackery}}: bit twiddling) |
||
Line 3,651:
<pre> 1 1
2 10
3 100
4 101
5 1000
6 1001
7 1010
8 10000
9 10001
10 10010
11 10100
12 10101
13 100000
14 100001
15 100010
16 100100
17 100101
18 101000
19 101001
20 101010</pre>
===Bit Twiddling===
The task notes:
::The Zeckendorf form can be iterated by some bit twiddling rather than calculating each value separately but leave that to another separate task.
That other separate task is [[Zeckendorf arithmetic]], specifically the ''optional'' increment function which, at the time of writing, has not been addressed in any of the languages present on the page. So here it is.
<lang Quackery> [ dup 1 >> ~ tuck - & ] is zinc ( n --> n )
0 21 times
[ i^ dup
10 < if sp
echo sp
dup binecho cr
zinc ]
drop</lang>
{{out}}
<pre> 0 0
1 1
2 10
3 100
|