Code Lab

Modo entrevista. Cronômetro de 5 min, sem dicas e sem autocompletar

Largest multiple

FácilArrays5 min

Write a function maxMultiple(numbers, n) that returns the largest element of an array that divides by n with no remainder. If there is none, return null. n is a whole number greater than zero.

Exemplos

maxMultiple([3, 10, 6, 15, 8], 3)

Retorna 15

maxMultiple([4, 7], 5)

Retorna null

maxMultiple([-9, -3, 4], 3)

Retorna -3

Of -9 and -3 the larger one is -3.

Cobrada em Snapdeal · Fonte

Carregando o editor...
  1. EntradamaxMultiple([ 3, 10, 6, 15, 8 ], 3)
    Esperado15
  2. EntradamaxMultiple([ 4, 7 ], 5)
    Esperadonull
  3. EntradamaxMultiple([ -9, -3, 4 ], 3)
    Esperado-3

Os testes ocultos rodam no envio