Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5594 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 783 |

@Manikanta punnam | 605 |

@sriramgoparaju99 | 582 |

@rdakka | 534 |

@praveenbgp6 | 529 |

@prankursharma31 | 518 |

@yashkaril4 | 517 |

@purohitmn02 | 467 |

@sonamnigam1999 | 443 |

@sonamkumari63928 | 441 |

@shubhamstudent5 | 433 |

Complete Leaderboard |

Given two integers **L** and **R**, write a program that finds the count of numbers having prime number of set bits in their binary representation in the range [L, R].

**Example 1:**

**Input**: L = 6, R = 10
**Output:** 4
**Explanation**: 6, 7, 9, 10 having
prime set bits between 6 and 10.

**Example 2:**

**Input: **L = 10, R = 15
**Output: **5
**Explanation**: 10, 11, 12, 13, 14 having
prime set bits between 10 and 15.

**Your Task: **

You dont need to read input or print anything. Complete the function **primeSetBits() **which takes L and R as input parameter and returns the count of numbers having prime number of set bits in their binary representation.

**Expected Time Complexity:** O(nlog(n)sqrt(n))

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= L <= R <=1000

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Prime number of set bits

...