The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
JAVA
By Guest on 6th March 2019 02:49:23 AM | Syntax: JAVA | Views: 3



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. public class Fibonacci {
  2.  
  3.     public static void main(String[] args) {
  4.  
  5.         int n = 10, t1 = 0, t2 = 1;
  6.         System.out.print("First " + n + " terms: ");
  7.  
  8.         for (int i = 1; i <= n; ++i)
  9.         {
  10.             System.out.print(t1 + " + ");
  11.  
  12.             int sum = t1 + t2;
  13.             t1 = t2;
  14.             t2 = sum;
  15.         }
  16.     }
  17. }



  • Recent Pastes