Created
November 28, 2011 11:55
-
-
Save pagenoare/1400143 to your computer and use it in GitHub Desktop.
random tasks
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
# coding: utf-8 | |
def main(): | |
try: | |
liczba = int(raw_input('Podaj liczbe: ')) | |
except: | |
print 'podany wyraz to nie liczba!' | |
if (liczba % 2 == 0) and (liczba >= 4 and liczba <= 100000000): | |
i = [liczba / 2, liczba / 2] | |
if (not liczba_pierwsza(i[0])) and (not liczba_pierwsza(i[1])): | |
while (not liczba_pierwsza(i[0])) or (not liczba_pierwsza(i[1])): | |
i[0] -= 1 | |
i[1] += 1 | |
print '%s + %s' % (i[0], i[1]) | |
def liczba_pierwsza(i): | |
for y in xrange(2, i): | |
if i % y == 0: | |
return False | |
return True | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment