Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution by Phan Dinh The #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions week0001/phandinhthe/Week0001.java
Original file line number Diff line number Diff line change
@@ -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;) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing around operators = <

if (i%3 == 0)
System.out.println("Fizz");
if (i%5 == 0)
System.out.println("Buzz");

additionFor3 = 3-(i%3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing around operators & parentheses - % ()

additionFor5 = 5-(i%5);

selectedAddition = additionFor3 > additionFor5 ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, this looks like a smart solution that jumps to the nearest multiple of 3 or 5.

additionFor5 : additionFor3;

i = i+selectedAddition;
}
}
}