FooBar problem Edit on GitHub

Here is a task. You need to write a Perl script that will output 100 lines.

Here is the example of the first four lines script should output:

1
2
Foo
4

There are several rules that define what should be on every line.

  • If other rules does not apply there should be line number in that line. The first line number is one.
  • If all the other rules does not apply and the line number is divisible by 3 (and there is no remainder of the division) then in that line should be written Foo.
  • If all the other rules does not apply and the line number is divisible by 5 (and there is no remainder of the division) then in that line should be written Bar.
  • If line number is divisible by 3 and at the same time it is divisible by 5 (and in both cases there is no remainder of the division) then in that line should be written FooBar.

The last line (as well as all the other lines) should end with new line symbol \n.

The code you enter will be saved as a file with a name script.pl and it will be run as perl script.pl. It will be run with perl 5.30.