Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecteuler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
projecteuler
Commits
e3869856
Commit
e3869856
authored
Dec 11, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimized 50
parent
1598cdc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
problem50.py
problem50.py
+11
-8
No files found.
problem50.py
View file @
e3869856
...
@@ -7,15 +7,18 @@ def maxprime(n):
...
@@ -7,15 +7,18 @@ def maxprime(n):
for
start
in
xrange
(
len
(
primes
)):
for
start
in
xrange
(
len
(
primes
)):
for
end
in
xrange
(
start
+
maxlen
+
1
,
start
+
800
):
for
end
in
xrange
(
start
+
maxlen
+
1
,
start
+
800
):
if
end
-
start
>=
maxlen
:
if
end
-
start
<
maxlen
:
conseq
=
primes
[
start
:
end
]
break
s
=
sum
(
conseq
)
if
len
(
conseq
)
>
1
and
s
in
primes
[
start
:]:
conseq
=
primes
[
start
:
end
]
maxlen
=
end
-
start
s
=
sum
(
conseq
)
maxp
=
s
print
maxp
if
s
>=
1000000
:
#print '%s = %d' % (' + '.join(map(str, primes[start:end])), s)
return
maxp
if
s
in
primes
[
start
+
maxlen
:]:
maxlen
=
end
-
start
maxp
=
s
return
maxp
return
maxp
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment