Created
March 20, 2014 15:54
-
-
Save markuskreitzer/9666993 to your computer and use it in GitHub Desktop.
Check to see if corresponding C and F values are prime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyprimes import isprime | |
''' | |
Quick little program I came up with. I was driving around Auburn when I | |
wondered what temperatures could be prime for both F and C. | |
(C) Markus Kreitzer, 2014 | |
This work is licensed under the Creative Commons | |
Attribution-NonCommercial-ShareAlike 4.0 International License. | |
To view a copy of this license, | |
visit http://creativecommons.org/licenses/by-nc-sa/4.0/. | |
''' | |
def toF(celsius): | |
""" | |
Check to make sure that the resulting F calc is an integer also. If it | |
isn't, we return a False which can be caught later. | |
""" | |
a = celsius * 9 | |
if a % 5 != 0: | |
return False | |
#### END if | |
return a/5 + 32 | |
#### END toF | |
def check_C_F(C): | |
if not isprime(C): | |
return False | |
#### END if | |
F = toF(C) | |
if F == False or F < 0 or not isprime(F): | |
return False | |
#### END if | |
return C,F | |
#### END check_C_F | |
ranger = 1000000 | |
for num in range(1,ranger): | |
numbers = check_C_F(num) | |
if numbers == False: | |
pass | |
else: | |
print "%i degC, %i degF" % numbers | |
#### END if | |
#### END for | |
print "DONE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment