Sobes.tech
Intern — Middle

Output words for numbers divisible by 2, 3, and 6

livecode

Task condition

Write a program that iterates through all integers from 1 to 100,000 and applies the following rules to each:

  • if the number is divisible by 2 without a remainder, output "Foo";
  • if the number is divisible by 3 without a remainder, output "Bar";
  • if the number is divisible by both 2 and 3 (i.e., by 6), output "Buzz";
  • in all other cases, output the number itself.