count =0
sumPrim = 0
print("all prim number", 0," to ", number," is ")
while(count<number):
if(count!=1):
if((count==2)|(count==3)|(count==5)|(count==7)):
sumPrim=sumPrim+count
print (count)
elif((count%2!=0)&(count%3!=0)&(count%5!=0)&(count%7!=0)):
sumPrim=sumPrim+count
print (count)
count = count+1
print ("sum primnumber",0," to ",number,"is")
print (sumPrim)
sumPrim(100)
ผลลัพธ์
all prim number 0 to 100 is 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 sum primnumber 0 to 100 is 1060
ไม่มีความคิดเห็น:
แสดงความคิดเห็น