Skip to content

primelib #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project Euler/Problem 01/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Find the sum of all the multiples of 3 or 5 below N.
'''
n = int(raw_input().strip())
sum=0;
sum=0
for a in range(3,n):
if(a%3==0 or a%5==0):
sum+=a
print sum;
print sum
6 changes: 3 additions & 3 deletions Project Euler/Problem 01/sol3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
This solution is based on the pattern that the successive numbers in the series follow: 0+3,+2,+1,+3,+1,+2,+3.
'''
n = int(raw_input().strip())
sum=0;
num=0;
sum=0
num=0
while(1):
num+=3
if(num>=n):
Expand Down Expand Up @@ -39,4 +39,4 @@
if(num>=n):
break
sum+=num
print sum;
print sum
6 changes: 4 additions & 2 deletions Project Euler/Problem 02/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
'''

n = int(raw_input().strip())
i=1; j=2; sum=0
i=1
j=2
sum=0
while(j<=n):
if((j&1)==0): #can also use (j%2==0)
sum+=j
temp=i
i=j
j=temp+i
print sum
print sum
8 changes: 4 additions & 4 deletions Project Euler/Problem 03/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def isprime(no):
return False
return True

max=0
maxNumber = 0
n=int(input())
if(isprime(n)):
print n
Expand All @@ -31,8 +31,8 @@ def isprime(no):
for i in range(3,n1,2):
if(n%i==0):
if(isprime(n/i)):
max=n/i
maxNumber = n/i
break
elif(isprime(i)):
max=i
print max
maxNumber = i
print maxNumber
34 changes: 34 additions & 0 deletions Project Euler/Problem 29/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def main():
"""
Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5:

22=4, 23=8, 24=16, 25=32
32=9, 33=27, 34=81, 35=243
42=16, 43=64, 44=256, 45=1024
52=25, 53=125, 54=625, 55=3125
If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by ab for 2 <= a <= 100 and 2 <= b <= 100?
"""

collectPowers = set()

currentPow = 0

N = 101 # maximum limit

for a in range(2,N):

for b in range (2,N):

currentPow = a**b # calculates the current power
collectPowers.add(currentPow) # adds the result to the set


print "Number of terms ", len(collectPowers)


if __name__ == '__main__':
main()
Loading