-2
Here is one more "Challenge"! Today i had a meeting with a friend, and mostly we are a little bit crazy.. He bets, that it is not possible to create a Fibonacci Sequence without using loops.
No static output like:
return "1, 2, 3, 5, 8, 13, ..";
GOAL / Requirements
- Use only 1 int var
- Return the first 5 (or more) numbers
- Name your function "fibonacci"
- Call no other functions except "fibonacci"
- No loops are allowed
- Have fun ;)
Scoring
Popularity contest (Most upvotes minus downvotes)
End Date
June 17. 2014
No special language required
2Two days for the contest? – Kyle Kanos – 2014-06-10T19:40:37.177
^ What do you think is okay? – Tyralcori – 2014-06-10T19:44:28.867
1Typically, 1 week is what is used. – Kyle Kanos – 2014-06-10T19:44:50.263
^ thx. Let's raise the end date – Tyralcori – 2014-06-10T19:48:49.777
When you say "Call no other functions", how do you define "function"? Is addition a function? – Ypnypn – 2014-06-10T19:53:46.387
Like what? Only recursive calls are allowed - that must be enough. – Tyralcori – 2014-06-10T19:54:46.807
@Tyralcori It's not. Recursion without any other functions can't do anything. – Ypnypn – 2014-06-10T19:59:37.080
@Ypnypn sorry, but i think, you are pretty wrong.. Look at MT0's answer ;) – Tyralcori – 2014-06-10T20:01:14.243
@Tyralcori That answer uses two functions: addition and subtraction. – Ypnypn – 2014-06-10T20:02:09.137
@Ypnypn okay, this "function" / addition is allowed and important. – Tyralcori – 2014-06-10T20:03:44.517
@Ypnypn: At least in JavaScript,
+
is an operator, not a function. – Dennis – 2014-06-10T20:09:45.297@Dennis my words, but i wanna point this out for Ypnypn – Tyralcori – 2014-06-10T20:10:03.933
possible duplicate of Fibonacci function or sequence
– Digital Trauma – 2014-06-10T20:27:44.320Recursion is a loop. What does "use only 1 int var" mean a) for use of non-int variables? b) for stack-based languages? c) for languages whose only primitives are combinators? – Peter Taylor – 2014-06-10T22:13:33.730