From e8a739cf2392733efff956554854f8d9554889db Mon Sep 17 00:00:00 2001 From: Aman Chauhan <48275253+amanchauhan06@users.noreply.github.com> Date: Thu, 29 Oct 2020 11:37:05 +0530 Subject: [PATCH] javaFibonacci Java Program to display the series --- javaFibonnaci | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 javaFibonnaci diff --git a/javaFibonnaci b/javaFibonnaci new file mode 100644 index 0000000..e0f0779 --- /dev/null +++ b/javaFibonnaci @@ -0,0 +1,17 @@ +public class Fibonacci { + + public static void main(String[] args) { + + int n = 10, t1 = 0, t2 = 1; + System.out.print("First " + n + " terms: "); + + for (int i = 1; i <= n; ++i) + { + System.out.print(t1 + " + "); + + int sum = t1 + t2; + t1 = t2; + t2 = sum; + } + } +}