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
21186ede
Commit
21186ede
authored
Dec 01, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some common functions to 'utils'
parent
4a07d490
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
31 deletions
+20
-31
frac.py
frac.py
+0
-8
problem243.py
problem243.py
+1
-1
problem33.py
problem33.py
+1
-1
problem41.py
problem41.py
+9
-21
utils.py
utils.py
+9
-0
No files found.
frac.py
deleted
100644 → 0
View file @
4a07d490
def
_gcd
(
a
,
b
):
while
b
:
a
,
b
=
b
,
a
%
b
return
a
def
gcd
(
*
args
):
return
reduce
(
_gcd
,
args
)
problem243.py
View file @
21186ede
#!/usr/bin/env python
#!/usr/bin/env python
from
__future__
import
division
from
__future__
import
division
from
prime
s
import
is_prime
,
nprimes
from
util
s
import
is_prime
,
nprimes
print
list
(
nprimes
(
15499
))
print
list
(
nprimes
(
15499
))
import
sys
;
sys
.
exit
()
import
sys
;
sys
.
exit
()
...
...
problem33.py
View file @
21186ede
#!/usr/bin/env python
#!/usr/bin/env python
from
__future__
import
division
from
__future__
import
division
from
itertools
import
combinations
,
permutations
from
itertools
import
combinations
,
permutations
from
frac
import
gcd
from
utils
import
gcd
nrs
=
[(
i
,
str
(
i
))
for
i
in
xrange
(
10
,
100
)]
nrs
=
[(
i
,
str
(
i
))
for
i
in
xrange
(
10
,
100
)]
pairs
=
((
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
))
pairs
=
((
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
))
...
...
problem41.py
View file @
21186ede
#!/usr/bin/env python
#!/usr/bin/env python
def
is_prime
(
n
):
from
utils
import
is_prime
if
n
==
2
:
return
True
if
n
<
2
or
not
n
&
1
:
from
itertools
import
permutations
return
False
for
i
in
xrange
(
3
,
int
(
n
**
.
5
)
+
1
,
2
):
m
=
0
if
not
divmod
(
n
,
i
)[
1
]:
return
False
return
True
for
i
in
xrange
(
2
,
10
):
if
__name__
==
'__main__'
:
from
itertools
import
permutations
m
=
0
for
i
in
xrange
(
2
,
10
):
for
digits
in
permutations
(
map
(
str
,
range
(
i
,
0
,
-
1
))):
for
digits
in
permutations
(
map
(
str
,
range
(
i
,
0
,
-
1
))):
n
=
int
(
''
.
join
(
digits
))
n
=
int
(
''
.
join
(
digits
))
if
n
>
m
and
is_prime
(
n
):
if
n
>
m
and
is_prime
(
n
):
m
=
n
m
=
n
print
m
print
m
prime
s.py
→
util
s.py
View file @
21186ede
def
_gcd
(
a
,
b
):
while
b
:
a
,
b
=
b
,
a
%
b
return
a
def
gcd
(
*
args
):
return
reduce
(
_gcd
,
args
)
def
is_prime
(
n
):
def
is_prime
(
n
):
if
n
==
2
:
if
n
==
2
:
return
True
return
True
...
...
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