<jupyter_start><jupyter_text>prime_factors<jupyter_code>import math

def primefactors(n):
    
    #base prime factor for an even no
    # eg. let n=4, so 4%2==0 now the no becomes 2 
    if n%2==0:
        print(2)
        n=n/2
    
    #if the number is odd
    #eg. if the number n=30, range(3, 6, 2) so if 30%3==0
    #    n becomes 10 now, 10%4 !=0 but 10%5==0 so no becomes n=2, we go to first condition
    
    for i in range(3, int(math.sqrt(n))+1, 2):
        if n%i==0:
            print(i)
            n=n/i
    if n>2:
        print(int(n))
primefactors(30)<jupyter_output><empty_output><jupyter_text>----------------------------------------------------  isprime or composite<jupyter_code>import math

def isprime(n):
    
    if n==1 or n==0:
        return "Neither"
    
    if n==2:
        return "Prime"
    
    while n%2==0:
        for i in range(2, int(math.sqrt(n)), 2):
            return "Composite Number"
    
    return "Prime"
isprime(100)
isprime(5)
isprime(0)
isprime(1)
isprime(2)<jupyter_output><empty_output><jupyter_text>------------------------------------------------------------------------------------------  Next Prime<jupyter_code>import math

def isprime(n):
    
    if n == 2:
        return True

    if n % 2 == 0:
        return False

    for i in range(3, int(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False

    return True


isprime(8)
def nextprime(currp):
    
    nexp=currp+1
    
    while True:
        if not isprime(nexp):
            nexp=nexp+1
        else:
            break
            
    return nexp
nextprime(5)
nextprime(7)
currp = 2
while True:
    answer = input('Would you like to see the next prime? (Y/N) ')
    if answer.lower().startswith('y'):
        print(currp)
        currp = nextprime(currp)
    else:
        break<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1880064829821718, 'fraction_numerical': 0.03403565640194489, 'mean_word_length': 1.6724386724386724, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '408333', 'license': 'Apache-2.0', 'n_tokens_mistral': 680, 'n_tokens_neox': 640, 'n_words': 173, 'path': 'Python Projects/Prime Factors, Prime Nos and Next Prime.ipynb', 'repo_name': 'divyansh1195/Python-Bootcamp-2020', 'size': '1851'}