Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4038f3d

Browse files
authored
Create isPrime.py
1 parent78d8a9b commit4038f3d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎allalgorithms/numeric/isPrime.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: UTF-8 -*-
2+
#
3+
# Check if is prime
4+
# The All ▲lgorithms library for python
5+
#
6+
# Contributed by: Natan Lucena
7+
# Github: @NatanLucena
8+
#
9+
10+
defisPrime(n) :
11+
12+
if (n<=1) :
13+
returnFalse
14+
if (n<=3) :
15+
returnTrue
16+
17+
if (n%2==0orn%3==0) :
18+
returnFalse
19+
20+
i=5
21+
while(i*i<=n) :
22+
if (n%i==0orn% (i+2)==0) :
23+
returnFalse
24+
i=i+6
25+
26+
returnTrue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp