PPaste!

sol.py

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!usr/bin python3

def is_prime(x: int) -> bool:
    if x <= 1:
        return True
    
    for y in range(2, x):
        if not x % y:
            return False
    
    return True

x = int(input('Enter the value of number X: '))

if not is_prime(x):
    factors = []
    for val in range(2, x):
        if not x % val:
            factors.append(str(val))
    print('Number is not prime. Factors of number %s are: ' % str(x) + ', '.join(factors))
else:
    print('The number %s is a prime number' % str(x))
    
print('Printing the value of function y = 8x^2 + 1')

for val in range(x-5, x+5):
    print('for value: %s, Function y = %s' % (str(val), str(8 * (x**2) + 1)))