A script that returns 0, 1 attached to the first Python prime number

There are many scripts out there that return prime numbers, The neck was that it didn't contain 0s and 1s. So, I made a script that adds 0 and 1 to an array of prime numbers and returns it.

Test.py



>>> def Test(a):
...     for i in range(a):
...             if i >= 2 and a%i == 0 :
...                     return False
...     return True
...
>>> [i for i in range(10) if Test(i)]
[0, 1, 2, 3, 5, 7]


Recommended Posts

A script that returns 0, 1 attached to the first Python prime number
[Python] A program that calculates the number of socks to be paired
[Python] A program that counts the number of valleys
A python script that gets the number of jobs for a specified condition from indeed.com
How to find the first element that matches your criteria in a Python list
[python] Change the image file name to a serial number
A Python script that saves a clipboard (GTK) image to a file.
Creating a Python script that supports the e-Stat API (ver.2)
[Python] The first step to making a game with Pyxel
A python script that converts Oracle Database data to csv
A Python script that compares the contents of two directories
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
A Python script that goes from Google search to saving the Search results page at once
A Python script that allows you to check the status of the server from your browser
[Python] A program to find the number of apples and oranges that can be harvested
Create a shell script to run the python file multiple times
A program that determines whether a number entered in Python is a prime number
[python] A note that started to understand the behavior of matplotlib.pyplot
[Python] A program that rotates the contents of the list to the left
Run the Python interpreter in a script
[Python] A program that rounds the score
How to run a Maya Python script
[Python] A program that calculates the number of chocolate segments that meet the conditions
"Python Kit" that calls a Python script from Swift
A python amateur tries to summarize the list ②
Judge whether it is a prime number [Python]
[Python] Throw a message to the slack channel
A solution to the problem that the Python version in Conda cannot be changed
A Python script that reads a SQL file, executes BigQuery and saves the csv
[Python] Solution to the problem that elements are linked when copying a list
[Python] A program that calculates the number of updates of the highest and lowest records
Convert the cURL API to a Python script (using IBM Cloud object storage)
I made a script to record the active window using win32gui of Python
A python script that generates a sample dataset for checking the operation of a classification tree
A Python script that crawls RSS in Azure Status and posts it to Hipchat
Check if the string is a number in python
python beginners tried to predict the number of criminals
Create a python script to check if the link at the specified URL is valid 2
I made a prime number generation program in Python
Template of python script to read the contents of the file
How to get the number of digits in Python
A story that got stuck when trying to upgrade the Python version on GCE
The first algorithm to learn with Python: FizzBuzz problem
[Ansible] Example of playbook that adds a character string to the first line of the file
Create a python script to check if the link at the specified URL is valid
[Python] A program that finds the shortest number of steps in a game that crosses clouds
A memorandum to run a python script in a bat file
# Function that returns the character code of a string
What's in that variable (when running a Python script)
[Python] How to write a docstring that conforms to PEP8
The first step to getting Blender available from Python
[Python] A convenient library that converts kanji to hiragana
A memo that I touched the Datastore with python
I made a prime number generation program in Python 2
I felt that I ported the Python code to C ++ 98.
Try to create a waveform (audio spectrum) that moves according to the sound with python
Python script to create a JSON file from a CSV file
Prime number 2 in Python
A python script that wants to use Mac startup / end time for attendance management
[Python] A program that compares the positions of kangaroos.
Python Note: The mystery of assigning a variable to a variable