Difference between revisions of "Fibonacci sequence"
From CompSciWiki
Line 26: | Line 26: | ||
An image or By Students section | An image or By Students section | ||
− | |Solution= | + | |Solution=public class Fibonacci |
+ | { | ||
+ | public static void main(String[] args) | ||
+ | { | ||
+ | int answer = 0; | ||
+ | |||
+ | for(int n = 1; n < 11; n++) | ||
+ | { | ||
+ | if(n == 0 || n == 1) | ||
+ | answer = answer + 1; | ||
+ | |||
+ | else | ||
+ | answer = answer + | ||
+ | } | ||
+ | } | ||
+ | } | ||
}} | }} |
Revision as of 12:48, 1 April 2010
Back to the Program-A-Day homepage
ProblemWrite a complete Java program Fibonacci that:
|
...by students
An image or By Students section | |
---|---|---|
Solutionpublic class Fibonacci { public static void main(String[] args) { int answer = 0; for(int n = 1; n < 11; n++) { if(n == 0 | ||
Code |