forked from architsingla13/InterviewBit-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzBuzz.java
More file actions
35 lines (29 loc) · 652 Bytes
/
FizzBuzz.java
File metadata and controls
35 lines (29 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package Math;
import java.util.ArrayList;
/**
* Author - archit.s
* Date - 28/09/18
* Time - 11:59 AM
*/
public class FizzBuzz {
public ArrayList<String> fizzBuzz(int A) {
ArrayList<String> ans = new ArrayList<>();
for(int i=1;i<=A; i++){
if(i%3 == 0){
if(i%5==0){
ans.add("FizzBuzz");
}
else{
ans.add("Fizz");
}
}
else if(i%5 == 0){
ans.add("Buzz");
}
else{
ans.add(""+i);
}
}
return ans;
}
}