Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Seeking easier code for 1, 2, 5, 10, 20, 50... sequence

1 view
Skip to first unread message

James Waldby

unread,
Sep 14, 2009, 3:21:45 AM9/14/09
to
perl -e '$m=1; while($m<10001){print " $m"; $m*=(5-$m%9%2)/2;}'

produces:

1 2 5 10 20 50 100 200 500 1000 2000 5000 10000

I've been trying to find some shorter code for this
than the $m*=(5-$m%9%2)/2; expression, but no luck.

Any ideas?

--
jiw

Loki Harfagr

unread,
Sep 14, 2009, 8:14:46 AM9/14/09
to
Mon, 14 Sep 2009 02:21:45 -0500, James Waldby did cat :

If you're nor absolutely looking after something strictly computational
maybe something around this cheat?

m=10^p++; printf "%d %d %d ",m,m*2,m*5;

0 new messages