in reply to Re^2: &1 is no faster than %2 when checking for oddness. Oh well.
in thread &1 is no faster than %2 when checking for oddness. Oh well.
This is mostly in jest but it does illustrate that programmer knowledge of the specific task at hand is more valuable then generalizations. There are similar formulas for summing just the odd or even numbers from 1 .. N as well.use Math::BigInt; my $sum = Math::BigInt->new(2); $sum->bpow(30); $sum = ($sum * $sum + $sum) / 2; print $sum; __DATA__ 576460752840294400
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: &1 is no faster than %2 when checking for oddness. Oh well.
by BrowserUk (Patriarch) on Nov 16, 2006 at 19:00 UTC | |
by Limbic~Region (Chancellor) on Nov 16, 2006 at 20:13 UTC | |
by BrowserUk (Patriarch) on Nov 16, 2006 at 20:21 UTC |