In: Computer Science
Name your program file warmup.py
Submit your working Python code to your CodePost.io account.
In this challenge, establish if a given integer num is a Curzon number. If 1 plus 2 elevated to num is exactly divisible by 1 plus 2 multiplied by num, then num is a Curzon number.
Given a non-negative integer num, implement a function that returns True if num is a Curzon number, or False otherwise.
Examples
is_curzon(5) ➞ True 2 ** 5 + 1 = 33 2 * 5 + 1 = 11 33 is a multiple of 11
is_curzon(10) ➞ False 2 ** 10 + 1 = 1025 2 * 10 + 1 = 21 1025 is not a multiple of 21
is_curzon(14) ➞ True 2 ** 14 + 1 = 16385 2 * 14 + 1 = 29 16385 is a multiple of 29
Write a Python program that reads in an integer. Make sure the integer is positive (including zero). If it is then output the sum of the Curzon numbers that exist between 0 and the number. If the number is not positive then output an error message "input not valid" on a line by itself.
Repeat this process until you read in a zero, then stop.
Add the following comments to EVERY Python program for this course
# Your Name # CSCI 236 # Date # Program 00 - Warmup # approximate number of hours you invested # Grade Version (some programs will have A, B, C versions, this one does not) # description of any major problems you ran into # status of the program - does it compile, does it run perfectly, does it have bugs, any limitations, etc
#funnction for curzon check number
def is_curzon(num):
#make a temporary number with given first condition
cond1 = 2**number + 1
#make second temporary number
cond2 = 2*number + 1
#check for given condition
if cond1 % cond2 == 0:
return True
else:
return False
number = int(input("Enter any positive integer: "))
#Check if the number is positive
if number >= 0:
#if positive proceed to calling the isCurzon function
print(is_curzon(number))
#If not positive number, print the error message
else:
print("input not valid")
#output