Created
October 22, 2016 10:32
-
-
Save ramithuh/7da24eb589250206d5b0211e1d8f2327 to your computer and use it in GitHub Desktop.
project euler 347
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
import math | |
arr=[] | |
#this is for prime | |
def isprime(k): | |
if(k==1 or k==0): | |
return 0 | |
for i in range(2,int(k**(0.5))+1): | |
if(k%i==0): | |
return 0 | |
arr.append(k) | |
return 1 | |
#largest eka | |
def largest(h,p1,p2): | |
if(h%p1==0 and h%p2==0): | |
for i in range(0,len(arr)): | |
if(h%arr[i]==0 and (arr[i]!=p1 and arr[i]!=p2)): | |
return 0 | |
return 1 | |
else: | |
return 0 | |
N=100 | |
for i in range(0,N): | |
isprime(i) | |
print "generate primes.. - done!" | |
sum=0 | |
print "- going... " | |
for i in range(0,len(arr)): | |
for j in range(i+1,len(arr)): | |
for k in range(N,0,-1): | |
if(largest(k,arr[i],arr[j])): | |
#print arr[i]," ",arr[j]," -",k | |
sum+=k | |
break | |
print sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment