Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.
l=int(input("Enter the integer L : ")) r=int(input("Enter the integer R: ")) A=[] prime=0 for i in range(l,r+1): count=bin(i).count('1') flag=0 for k in range(2,r+1): if count%k==0 and count!=k : flag=1 break if(flag==0 and count!=1): prime+=1 print(prime)
Input:
Enter the integer L : 6
Enter the integer R: 10
Output:
4
Input:
Enter the integer L : 10
Enter the integer R: 15
Output:
5
Output:
Enter the integer L : 6
Enter the integer R: 10
4
Output:
Enter the integer L : 10
Enter the integer R: 15
5
Output:
Enter the integer L : 20
Enter the integer R: 30
7
Output:
Enter the integer L : 20
Enter the integer R: 20
1
Output:
Enter the integer L : 6
Enter the integer R: 8
2
More Codes to Fcuk
- Armstrong Number
- Find the biggest even number
- Program to replace every element on right side
- Compute the frequency of the note
- Print all Possible Combinations from three Digits.
- Get number n and Compute n+nn+nnn
- Print Cube root of the given number
- Convert number into binary, octal and hexa
- Return maximum number of operations performed on array.
- Determine the encryption key
- Find the count of numbers having a prime number in their binary representation.
- Fibonacci Series up to given n numbers
- Help Alice find the route to her home
Explore
- Quantum Mechanics relation with quantum computing
- Unzipping Files using Python
- An Algorithm which accepts n integer values and calculates the average and prints it.
- How can Quantum Computing merge with Virtual Reality ? !
- Blockchain and Cryptocurrency. And their relations with Virtual Reality !!