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

 

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

A non-negative integer 'num' is passed in as a parameter. Your goal is to determine the bitwise parity of the binary representation of that number. For example, 5, in binary is 101. That binary representation has a even number of 1's and therefore has even parity. Write a method that returns 'true' if 'num' has even pairty or 'false' if 'num' has odd pairty. Note that this is NOT about whether 'num' is an even number or not. It IS about the number of 1's in the binary representation of 'num'.


test2023_11_02_SLHL_pairty(154) → true
test2023_11_02_SLHL_pairty(22) → false
test2023_11_02_SLHL_pairty(345) → false

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

public boolean test2023_11_02_SLHL_pairty(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: 280

Copyright Nick Parlante 2017 - privacy