0

Coding Challenge: Cool Numbers

The "coolness" of a whole number n is defined by the number of occurrences of "101" in the binary representation of n. For example, the coolness of 21 is defined as 2. This is because the binary representation of 21 (which is 10101) has 2 occurrences of the sequence "101". n is defined as "very cool" if it's coolness is greater than or equal to a whole number k. Your task is to write a program that computes the number of very cool numbers between 1 and R, including a defined k input. Input: First line: R Second line: k Output: Number of very cool numbers between 1 and R Constraints: 1<=R<=100 1<=k<=100 Good luck!

19th Aug 2017, 8:19 PM
Erik Johanson
Erik Johanson - avatar
2 odpowiedzi
+ 1
Here you go. Checks for valid numerical input. https://code.sololearn.com/cXq3deusKXBY/?ref=app
20th Aug 2017, 3:12 AM
Vari93
Vari93 - avatar
- 2
HERES THE NEW CHALLENGE... CHECK IT OUT FRIENDS https://www.sololearn.com/discuss/653982/?ref=app
24th Aug 2017, 6:52 PM
sayan chandra
sayan chandra - avatar