Over a million developers have joined DZone.

Code Golf: Fibonacci's Sequence Part Deux

DZone's Guide to

Code Golf: Fibonacci's Sequence Part Deux

· IoT Zone ·
Free Resource

When it comes to ingenuity, Code Golf is my absolute favorite thing in the developer space. Code Golf, like the game of golf, is an exercise in brevity - the fewest lines of code and the smaller the file size, the better. It requires creativity, knowledge of your craft, and perseverance.

So in order to showcase the brightest members of our community, DZone will be holding a weekly Code Golf competition.

What's in it for you? The winner every week will receive some awesome DZone swag!

Just ask Milan Pavlović, last week's winner!

In order to submit your entry, you'll need to leave a comment with your code (using the code feature), as well as what language you used. Your code must be completely self-contained (don't reference code external to your own!)

So, let's get started!

This week's challenge:

You'll need to output Fibonacci's sequence to the 30th factor. Your output should look something like this:

1 : 1
2 : 1
3 : 2
30 : 832040

Your output must include all 30 numbers (1-30 and their equivalent Fibonacci number).

The catch? You cannot use ANY NUMBERS in your code!

The code with the fewest characters (excluding whitespace) will be the winner! You must submit your code by Tuesday, February 24. The winner will be announced in our Newsletter!

Sound like something you can handle? We'd like to see you try.

Happy coding!


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}