new prime python
This commit is contained in:
parent
2d406ad821
commit
8fdc549f13
2
isprime-python/.idea/.gitignore
generated
vendored
Normal file
2
isprime-python/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Default ignored files
|
||||
/workspace.xml
|
6
isprime-python/.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
isprime-python/.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -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
generated
Normal file
20
isprime-python/.idea/isprime-python.iml
generated
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
generated
Normal file
6
isprime-python/.idea/libraries/R_User_Library.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="libraryTable">
|
||||
<library name="R User Library">
|
||||
<CLASSES />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
7
isprime-python/.idea/misc.xml
generated
Normal file
7
isprime-python/.idea/misc.xml
generated
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
generated
Normal file
8
isprime-python/.idea/modules.xml
generated
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
generated
Normal file
6
isprime-python/.idea/vcs.xml
generated
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.route('/')
|
||||
def isprime():
|
||||
n = os.environ.get('TARGET', '42069')
|
||||
if n == 2 or n == 3: return "Prime"
|
||||
if n < 2 or n%2 == 0: return "Not Prime"
|
||||
if n < 9: return "Prime"
|
||||
if n%3 == 0: return "Not Prime"
|
||||
r = int(n**0.5)
|
||||
f = 5
|
||||
while f <= r:
|
||||
if n%f == 0: return "Not Prime"
|
||||
if n%(f+2) == 0: return "Not Prime"
|
||||
f +=6
|
||||
return "Prime"
|
||||
num = os.environ.get('TARGET', '107107')
|
||||
if num > 1:
|
||||
# check for factors
|
||||
for i in range(2, num):
|
||||
if (num % i) == 0:
|
||||
return "not prime"
|
||||
else:
|
||||
return "not prime"
|
||||
|
||||
else:
|
||||
print(num, "is not a prime number")
|
||||
|
||||
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