Exercise 11: for Loops

Let's test your ability to write for loop.

Problem Statement

For each element in the given vector, print foo if it is a multiple of 33, bar if it is a multiple of 55 and foo bar if it’s a multiple of both 33 and 55.

Use the cat() function for printing. Remember to print the number as well as the respective statement!

Input

A testVariable containing the vector of numbers

Output

The element and the attached statement with it.

Sample Input

testVariable -> c(3, 5, 15)

Sample Output

3 foo 5 bar 15 foo bar

Test Yourself

Write your code in the given area. If you get stuck, you can look at the solution.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy