a simple note, it'll use 2*(2**$a) array elements, and is probably O(2**n) in memory usage and cpu time, so its probably one of the more ineffecient ways to calculate powers of three in existence$a=24;@a=(1);sub d{push@a,map{2*$_}@a}; d for('1'.."$a");$b=$#a;$_=0; push@b,$_+=$a[$#a-$b--] until($b==-1); print$b[2**$a-1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Powers of three
by zshzn (Hermit) on Feb 07, 2006 at 02:35 UTC | |
by simcop2387 (Acolyte) on Feb 07, 2006 at 07:55 UTC | |
by truedfx (Monk) on Feb 07, 2006 at 18:04 UTC | |
by tweetiepooh (Hermit) on Feb 10, 2006 at 11:09 UTC |