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

 

jebbert@volusia.k12.fl.us > test2022_01_20_BONUS_mostFactors
prev  |  next  |  chance

Write a method that returns the number from array 'nums' with the greatest number of distinct (different) factors that appear in array 'nums'. Keep in mind that those factors have to appear IN 'nums'! This is not just about which number has the greatest number of distinct factors. It is about which has the greatest number of distinct factors that appear in the array! This is also NOT about PRIME factors. Any distinct factors that appear in the array count. For clarity: 32 has the following distinct factors: 2, 4, 8, and 16. The number itself does not count as a factor, nor does 1. As preconditions you may assume that 'nums' will have no duplicates, that every element will be 2 or greater, and that there will be a number in 'nums' that has strictly MORE distinct factors than any of the other numbers in 'nums' (no ties for most distinct factors). Return the number with the most distinct factors in 'nums'. Look at the test data for examples.


test2022_01_20_BONUS_mostFactors([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) → 12
test2022_01_20_BONUS_mostFactors([25, 5, 72, 23, 18, 460, 10, 2]) → 460
test2022_01_20_BONUS_mostFactors([12, 8, 22, 66, 11, 3]) → 66

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

public int test2022_01_20_BONUS_mostFactors(int[] nums) { }

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: 290

Copyright Nick Parlante 2017 - privacy