Answer:
Following are the program in python language the name of the program is factors.py
num= int(input("Please enter a positive integer: "))#Read the number by user
print("The factors of ",num,"are:")
for k in range(2,num): #iterating over the loop
if(num%k==0): #checking the condition
print(k)#display the factor
Output:
Please enter a positive integer: 12
The factors of 12 are:
2
3
4
6
Explanation:
Following are the description of the program
- Read the number by user in the "num" variable
- Iterating the for loop from k=2 to less then "num".
- In the for loop checking the factor of "num" variable by using % operator.
- Finally display the factor by using print function
Answer:
B. 11110111
Explanation:
Binary representation of number 9 = 00001001
Binary representation of -9 would involve calculating the twos complement representation of 00001001
First we compute the ones complement of this number by reversing the bits.
00001001 => 11110110
Next we calculate the twos complement representation by adding 1 to the ones complement.
11110110+1 = 11110111
So the final representation is 11110111.