0
Multiples of array elements
Write a function that returns the first 'n' multiples of each number in an array of string. Do not include the number itself in the multiples. ``` getMultiples(array,n) ``` Where n is the number of multiples we need. Ex: ``` getMultiples ([1,7,2],3) ``` Result: ``` { 1:[2,3,4], 7:[14,21,28], 2:[4,6,8] } Solve in any language of your choice ``` https://code.sololearn.com/cS05Dk2JESsi/?ref=app
7 Respostas
+ 1
So it looks like we have to return something. So I would say a list of lists can do this.
Create a list for Integers and put in all multiples of one number of your array.
Create a list for lists in put in each of this sub-lists.
Then return this outer list:
It can be done, for example, like this:
https://code.sololearn.com/c3F1XO3rRjIj/?ref=app
+ 1
Oh ok...thanks
+ 1
Is it ok if I ask for guides from you some time later??...kotlin per se
+ 1
fun multiples(array:ArrayList<Int>, N:Int
for(i in array){
var list= arrayListOf<Int>() //move this line here
0
I'd like my answers to be in a list like that of the "results" above separately put together for each element..... I tried putting it in the list but it just puts all the elements in the array like a new array..pls help
0
And please don't tag Java, if you want to do something with Kotlin 😉
0
Can u share solution in Java as well?