Skip to content

Commit

Permalink
先写判定素数的函数然后再循环判断(注意题目中的要求是两个不同素数的和)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuglessCoder authored Mar 4, 2018
1 parent d27a8e2 commit 9e21746
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions 分拆素数和.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
n=2
def sushu(a):
n=10
def isPrime(a):
flag = 0
for i in range(2,a):
if a%i==0:
return False;
flag = 1
break;
return True;
if flag == 1:
return False
else:
return True
count=0
for i in range(2,n//2):
if(sushu(i) and sushu(n-i)):
count+=1;

for i in range(2,n//2+1):
if(isPrime(i) and isPrime(n-i) and i!=n-i):
count+=1;
print(count)


0 comments on commit 9e21746

Please sign in to comment.