-
Notifications
You must be signed in to change notification settings - Fork 0
/
task1.R
25 lines (24 loc) · 834 Bytes
/
task1.R
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
##-----------------------------------------------------------##
## Task 1 ##
##-----------------------------------------------------------##
# T1. Write a program that prints the numbers from 1 to 100. #
# But for multiples of three print "Hello" instead of the #
# number and for the multiples of five print "World". #
# For numbers which are multiples of both three and five #
# print "Hello World". #
##-----------------------------------------------------------##
for(i in 1:100){
if(i%%3 == 0){
if(i%%5 ==0){
print("Hello World")
}else{
print("Hello")
}
}else{
if(i%%5 ==0){
print("World")
}else{
print(i)
}
}
}