Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find a prime number

def prime_checker(number):
    is_prime = True
    for i in range(2, number):
        if number % i == 0:
            is_prime = False
    if is_prime:
        print(f"{number} is a prime number!")
    elif not is_prime:
        print(f"{number} is not a prime number!")
    else:
        return
      
n = int(input("Enter a number: "))
prime_checker(number=n)
Comment

find prime number

        vector<bool> isPrime(n,true);
        int count=0, k;
        for(int i=2;i<n;i++) {
            if(isPrime[i]) {
                count++;
                for(k=2;i*k<n;k++)
                    isPrime[i*k]=false;
            }
        }
Comment

find a prime number

if (x%2 > 0 && x%3 > 0 && x%5 > 0 && x%7 > 0)
	echo "Not a Prime Number";
else
	echo "Prime Number"
    
// If anyone finds this to be incorrect, please comment
// I created this conjecture
Comment

PREVIOUS NEXT
Code Example
Python :: python loop backward 
Python :: exponent in python 
Python :: properties of tuples in python 
Python :: python concatenation 
Python :: python beautifulsoup xpath 
Python :: how to find unique values in numpy array 
Python :: save pillow image to database django 
Python :: python random generator from list 
Python :: how to append in dictionary in python 
Python :: python input for competitive programming 
Python :: word2vec python 
Python :: python write into file at position 
Python :: python np get indices where value 
Python :: remove vowels in a string python 
Python :: table in sqlite python 
Python :: how to read first column of csv intro a list python 
Python :: xarray get number of lat lon 
Python :: python . 
Python :: make sure it only has letters and numbers python 
Python :: box plot in seaborn 
Python :: pyinstaller pymssql 
Python :: listas en python 
Python :: how to print during multiprocessing 
Python :: python for enumerate 
Python :: adam optimizer keras learning rate degrade 
Python :: pandas series remove element by index 
Python :: python argparser flags 
Python :: pandas knn imputer 
Python :: python conditions 
Python :: fizz buzz in python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =