Advertisement
Azazavr

Трибоначчи

Feb 22nd, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public class Tribonacci {
  2.  
  3.     public static void main(String[] args) {
  4.  
  5.         int n = 3;
  6.         int fn=0;
  7.         int fnMinus1 = 0;
  8.         int fnMinus2 = 0;
  9.         int fnMinus3 = 1;
  10.         int nMax = 15;
  11.  
  12.         while (n < nMax){
  13.             fn = fnMinus1+fnMinus2+fnMinus3;
  14.             System.out.print(fn + " ");
  15.             fnMinus1= fnMinus2;
  16.             fnMinus2 = fnMinus3;
  17.             fnMinus3 = fn;
  18.             n++;
  19.  
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement