some other solutions:
On a related note, I have a pdf titled "Perlgolf History" (first page is a big image of a squaking ostrich if anyone knows of it) -- i don't remember where I d/l'd it from and at the moment w/just a brief google search I can't find it..
But anyways, in its "Terje's PGAS season 0" section, it covers "Modular Fibonacci" (note that
2m is '2<super>m</super>'):
5.12. Modular Fibonacci
http://terje2.perlgolf.org/~pgas/score.pl?func=rules&hole=12&season=0
The game started 2002-10-21 21:30:00 and ended 2002-10-27 19:00:00.
5.12.1. Rules
The Fibonacci numbers (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...) are defi
+ned by the recurrence:
F1 = 1
F2 = 1
Fi = Fi-1 + Fi-2 for i > 2
Write a program which calculates Mn = Fn mod 2m for given pair of n an
+d m. 0 < n < 10000 and 0 <
m < 20 . Note that a mod b gives the remainder when a is divided by b.
Input consists of one newline-terminated line specifying a pair of n a
+nd m separated by a space.
Output should be corresponding Mn, and a newline.
Sample Input
11 7
Sample Output
89
5.12.2. Solutions
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.