new prime python

This commit is contained in:
Torma Kristóf 2019-10-10 15:34:57 +02:00
parent 2d406ad821
commit 8fdc549f13
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
8 changed files with 68 additions and 13 deletions

2
isprime-python/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

View 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
View 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>

View 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
View 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
View 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
View 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>

View File

@ -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)))