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

 

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

Write a method that returns how many factors of 2 a number has. For example, 40 has 3 factors of 2 because 40 can be factored into the primes 2*2*2*5. Some numbers do not have factors of 2, such as 13, 17, and 21. Other number has nothing but factors of 2, such as 64. In each case, return how many factors of 2 'num' has. As preconditions, you may assume that 'num' is non-negative. Look at the test data for examples.


test2025_05_22_APP1SL_factorsOfTwo(834) → 1
test2025_05_22_APP1SL_factorsOfTwo(482) → 1
test2025_05_22_APP1SL_factorsOfTwo(262144) → 18

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

public int test2025_05_22_APP1SL_factorsOfTwo(int num) { }

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

Copyright Nick Parlante 2017 - privacy