Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/exercises/en/4_fibonacci.py
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/en/4_fibonacci.py')
-rw-r--r--exercises/en/4_fibonacci.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/exercises/en/4_fibonacci.py b/exercises/en/4_fibonacci.py
new file mode 100644
index 0000000..825a7d7
--- /dev/null
+++ b/exercises/en/4_fibonacci.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+# coding=utf-8
+
+"""You must write code to print the first N numbers in the Fibonacci sequence.
+
+Your program must read N from the user, with the prompt 'How many Fibonacci
+numbers should be printed?'. It must then print the first N numbers from the
+sequence defined by:
+ F_0 = 0
+ F_1 = 1
+ F_n = F_{n - 1} + F_{n - 2}
+
+e.g. The sequence: 0, 1, 1, 2, 3, 5, 8, 13, ...
+"""
+total = int(raw_input('How many Fibonacci numbers should be printed? '))
+
+# Add your code here. Hint: use two variables to store most recent two values
+# in the sequence.