package au.com.d2klry; public class Fibonacci { public static void main(String[] args) { long prevValue = 1; long prevPrevValue = 0; long currentValue = 0; for (int i = 0; i < 20; i++) { prevPrevValue = prevValue; prevValue = currentValue; System.out.format("%d\t", currentValue); currentValue = prevValue + prevPrevValue; } } }
No comments:
Post a Comment