InterviewSolution
Saved Bookmarks
| 1. |
Write a Program in Java to display the first 10 numbers of the Fibonacci series |
|
Answer» public class Fibonacci { public static void main ( ) { int a, b, c; a = 0 b = 1; c = 0; n = 3; System.out.printIn (“The series is”); System.out.printIn (a); System.out.printIn (b); do // You can use any loop. Do while loop is comparatively straight forward. { c = a + b; System.out.println(c); a = b; b = c; n = n + 1; } while (n<=10); } } |
|