new prime python
This commit is contained in:
parent
2d406ad821
commit
8fdc549f13
2
isprime-python/.idea/.gitignore
vendored
Normal file
2
isprime-python/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/workspace.xml
|
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
20
isprime-python/.idea/isprime-python.iml
Normal file
20
isprime-python/.idea/isprime-python.iml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="Flask">
|
||||||
|
<option name="enabled" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="R User Library" level="project" />
|
||||||
|
<orderEntry type="library" name="R Skeletons" level="application" />
|
||||||
|
</component>
|
||||||
|
<component name="TemplatesService">
|
||||||
|
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
|
||||||
|
</component>
|
||||||
|
<component name="TestRunnerService">
|
||||||
|
<option name="projectConfiguration" value="pytest" />
|
||||||
|
<option name="PROJECT_TEST_RUNNER" value="pytest" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
isprime-python/.idea/libraries/R_User_Library.xml
Normal file
6
isprime-python/.idea/libraries/R_User_Library.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="R User Library">
|
||||||
|
<CLASSES />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
7
isprime-python/.idea/misc.xml
Normal file
7
isprime-python/.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
isprime-python/.idea/modules.xml
Normal file
8
isprime-python/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/isprime-python.iml" filepath="$PROJECT_DIR$/.idea/isprime-python.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
isprime-python/.idea/vcs.xml
Normal file
6
isprime-python/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -4,20 +4,20 @@ from flask import Flask
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def isprime():
|
def isprime():
|
||||||
n = os.environ.get('TARGET', '42069')
|
num = os.environ.get('TARGET', '107107')
|
||||||
if n == 2 or n == 3: return "Prime"
|
if num > 1:
|
||||||
if n < 2 or n%2 == 0: return "Not Prime"
|
# check for factors
|
||||||
if n < 9: return "Prime"
|
for i in range(2, num):
|
||||||
if n%3 == 0: return "Not Prime"
|
if (num % i) == 0:
|
||||||
r = int(n**0.5)
|
return "not prime"
|
||||||
f = 5
|
else:
|
||||||
while f <= r:
|
return "not prime"
|
||||||
if n%f == 0: return "Not Prime"
|
|
||||||
if n%(f+2) == 0: return "Not Prime"
|
else:
|
||||||
f +=6
|
print(num, "is not a prime number")
|
||||||
return "Prime"
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
|
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
|
||||||
|
Loading…
Reference in New Issue
Block a user