# Need scala code for below Lab requirement

Write a code to generate the first `input` multiples of 5 integers from `5` . If 3 is the input, the list must be List(5, 10, 15). Using the `for` loop, create an `yieldedList` with `yield` which contains elements smaller than 50 and are odd integers. Using another `for` loop, print all the multiples of 3 in the `yieldedList` .

`scala ForComprehensions2 3` .

Output will be:
List(5, 15)
15

I suspect that the point of the exercise is probably that you figure it out for yourself.

3 Likes

I am trying but without any luck, trying to go through the material as well but not able to convert that in code and the thing is that i need this code to proceed with lab and other learning module. so any help in providing the code is much appreciated.
Thank You.

You can use `if` in a for comprehension to filter out elements that you don’t want.

E.g. in the following code only numbers for which the fictional function `keepNumber` returns `true` will be yielded to a new list.

``````for(x <- list if keepNumber(x)) yield x
``````

Checking if a number is a multiple of some other number is usually done with the modulo operator `%`. `%` complements the division operator `/`.`/` returns the quotient while `%` returns the remainder. If `x % y` returns 0 that means that `x` is a multiple of `y`.