# [seqfan] Stern's diatomic revisited

Sat Mar 13 23:35:19 CET 2010

```Bonjour à tous !

SternsDiatomic := proc(m, i, j) local a, b, n;
a := i; b := j; n := m;
while n > 0 do
if n mod 2 = 1 then b := a + b else a := a + b fi;
n := iquo(n,2);
od; [a,b] end:

seq(op(1,SternsDiatomic(i,1,0)),i=0..32);
seq(op(2,SternsDiatomic(i,1,0)),i=0..32);
seq(op(1,SternsDiatomic(i,0,1)),i=0..32);
seq(op(2,SternsDiatomic(i,0,1)),i=0..32);
seq(op(1,SternsDiatomic(i,1,1)),i=0..32);
seq(op(2,SternsDiatomic(i,1,1)),i=0..32);

1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 3, 1, 2, 1, 1, 1, 4, 3, 5, 2, 5, 3,
4, 1, 3, 2, 3, 1, 2, 1, 1, 1
0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 5, 4, 7, 3, 8, 5,
7, 2, 7, 5, 8, 3, 7, 4, 5, 1
0, 0, 1, 0, 2, 1, 1, 0, 3, 2, 3, 1, 2, 1, 1, 0, 4, 3, 5, 2, 5, 3, 4,
1, 3, 2, 3, 1, 2, 1, 1, 0, 5
1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 5, 4, 7, 3, 8, 5, 7,
2, 7, 5, 8, 3, 7, 4, 5, 1, 6
1, 1, 2, 1, 3, 3, 2, 1, 4, 5, 5, 4, 3, 3, 2, 1, 5, 7, 8, 7, 7, 8, 7,
5, 4, 5, 5, 4, 3, 3, 2, 1, 6
1, 2, 3, 3, 4, 5, 5, 4, 5, 7, 8, 7, 7, 8, 7, 5, 6, 9, 11, 10, 11, 13,
12, 9, 9, 12, 13, 11, 10, 11, 9, 6, 7

Credit goes to E. Dijkstra and thanks to Igor Urbiha.
Enjoy!