A Short Perl Brain Teaser

Joel Meulenberg joelmeulenberg at yahoo.com
Mon Sep 27 12:37:47 CDT 1999


> If sub g is called with any positive integer it will converge upon
> the golden
> ratio.  The first call value is already equal to the golden ratio, so
> there isn't much convergence going on.  

Bingo.  Good call Rob!

(Actually, it converges on the golden ratio (approx .618) for most
negative numbers too.)
BTW, the obscenely large 9999...999 number was just to discourage
people from running the code and encourage thinking about it.  You can
change that to 99 and actually run it if you like.

The Golden Ratio is the one positive number that satisfies:

X = 1 / (1 + X)

(-1 / Golden_Ratio) satisfies it too.

So, it's definition is recursive.  It expands out like this:
1 / (1 + (1 / 1 + (1 / 1 + (1 / 1 + (...)))))

The ratio between adjacent numbers in a Fibonocci sequence converges on
the golden ratio.

The Greeks believed it to be the most esthetically pleasing ratio of
width to height.  It pops up all over in nature (even your head
dimensions).  Designers dig it (or so I'm told).

+Joel




=====
__________________________________________________
AdStream programs expose you to a stream of banner ads while you're
connected to the Internet.  In exchange for a smidgen of your attention
they pay you cash.  You can easily earn enough to pay your monthly ISP
bill.  Compare the various AdStream programs at:
http://adstreaminfo.hypermart.net/
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com



More information about the grand-rapids-pm-list mailing list