-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContents.swift
50 lines (39 loc) · 855 Bytes
/
Contents.swift
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// MARK: - FIND NUMS DIVIDED BY
var greeting = "Hello, playground"
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
for num in numbers{
if num % 3 == 0 && num % 5 == 0 {
print("\(num) FizzBuzz")
}
else{
if num % 3 == 0 {
print("\(num) Fizz")
}
else if num % 5 == 0 {
print("\(num) Buzz")
}
else{
print(num)
}
}
}
print("-------")
// MARK: - For One Thousands Numbers
var oneThousandsNumbers = [Int]()
for i in 1...1000{
oneThousandsNumbers.append(i)
}
for num in oneThousandsNumbers{
if num % 15 == 0 {
print("\(num) FizzBuzz")
}
else if num % 3 == 0 {
print("\(num) Fizz")
}
else if num % 5 == 0 {
print("\(num) Buzz")
}
else{
print(num)
}
}