FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
FactorCount/python/factor_count.py at master · IPochynyukCoding/FactorCount · GitHub
IPochynyukCoding
/
FactorCount
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
FactorCount
/
python
/
factor_count.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (24 loc) · 1.03 KB
Breadcrumbs
FactorCount
/
python
/
factor_count.py
Copy path
File metadata and controls
24 lines (24 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from
math
import
isqrt
def
main
():
while
True
:
potential
=
input
(
"Please input a number to check for prime or press 'q' to quit: "
)
factors
=
[]
if
potential
.
lower
()
==
"q"
:
quit
()
try
:
potential_num
=
int
(
potential
)
except
ValueError
:
print
(
"Please input a valid positive integer (number > 0)"
)
else
:
if
potential_num
<
1
:
print
(
"This number cannot be calculated for factors due to being smaller than one."
)
else
:
for
number
in
range
(
1
,
isqrt
(
potential_num
)
+
1
):
if
potential_num
%
number
==
0
:
factors
.
append
(
number
)
factors
.
append
(
potential_num
//
number
)
factors
=
sorted
(
list
(
set
(
factors
)))
print
(
f"The factors of
{
potential_num
}
are:
{
factors
}
"
)
print
(
f"
{
potential_num
}
is
{
'not '
if
len
(
factors
)
!=
2
else
''
}
prime, because it has
{
len
(
factors
)
}
factor(s)."
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL