From 45f550c8844357b123e476e6b43ecfece33945e9 Mon Sep 17 00:00:00 2001 From: phandinhthe Date: Sun, 6 Nov 2016 03:56:55 +0700 Subject: [PATCH] Solution by Phan Dinh The --- week0001/phandinhthe/Week0001.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 week0001/phandinhthe/Week0001.java diff --git a/week0001/phandinhthe/Week0001.java b/week0001/phandinhthe/Week0001.java new file mode 100644 index 0000000..71aec88 --- /dev/null +++ b/week0001/phandinhthe/Week0001.java @@ -0,0 +1,23 @@ +package phandinhthe; +public class Week0001 { + public static void main (String[] args) { + int additionFor3 = 0; + int additionFor5 = 0; + int selectedAddition = 1; + + for(int i=1; i<101;) { + if (i%3 == 0) + System.out.println("Fizz"); + if (i%5 == 0) + System.out.println("Buzz"); + + additionFor3 = 3-(i%3); + additionFor5 = 5-(i%5); + + selectedAddition = additionFor3 > additionFor5 ? + additionFor5 : additionFor3; + + i = i+selectedAddition; + } + } +}