These are optional exercises for practicing the concepts we learned this week.
Write a program that reads an integer N and prints the smallest power of 2 that is ≥ N.
Write a program that reads an integer N ≥ 1 and prints the largest power of 2 that is ≤ N.
Write a program that reads an integer and prints the sum of its digits.
Calculate by hand:
What is 1101002 in base 10? What is AB16 in base 10?
What is 9510 in base 2? In base 16?
In hexadecimal, what is the smallest and largest value that can be stored in a byte?
Write a program that reads an integer and prints it in hexadecimal (i.e. base 16).
Write a program that reads an integer N and prints out N with its digits reversed. Do not use any strings (except for reading the input) or lists. You must reverse the digits using arithmetic operations only.
For any n ≥ 0, the Fermat number Fn =
Fn = + 1
The first few Fermat numbers are F0 = 2, F1 = 5, F2 = 17, F3 = 257, which are all prime.
Fermat conjectured that all Fermat numbers are prime. Use Python to investigate the truth of this claim.