id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

apcsaArraysFindMultiples


Heads up, this is a harder problem. Congratulations on making it here!


Given an array arr of int values and a multiple n, find all values in arr that are multiples of n and return those as a new array containing only their values (in their original order from arr).

HINT: when you create a new array you need to know how many elements it stores.  You might need two loops for this problem.

CHALLENGE (difficult): solve this in one line.

apcsaArraysFindMultiples([3, 4, 5, 6, 7, 8, 9], 3) → [3, 6, 9]
apcsaArraysFindMultiples([3, 4, 5, 6, 7, 8], 3) → [3, 6]
apcsaArraysFindMultiples([1, 9, 2, 10, 3, 8, 4], 2) → [2, 10, 8, 4]

...Save, Compile, Run (ctrl-enter)

public int[] apcsaArraysFindMultiples(int[] arr, int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 260

Copyright Nick Parlante 2017 - privacy