ht

mail@pastecode.io avatar
unknown
python
2 months ago
1.7 kB
9
Indexable
Never
t = int(input("enter the program number: "))
if(t == 14):
    # 14
    for i in range(1, 10):
        for j in range(1, 10):
            print(i * j, end=" ")
        print("\n")
elif(t == 15):
    # 15
    n = int(input())  #натуральное!
    if n == 1:
        print(n)
    for i in range(1, n):
        if(n % i == 0):
            print(i, end=" ")
            if(i * i != n):
                print(int(n / i), end=" ")
        if (i+1) * (1+i) >= n:
            if ((1+i) * (1+i) == n):
                print(int(n / (i+1)), end=" ")
            break
elif t == 16:
    n = int(input())
    fl = True
    for i in range(2, n):
        if(n % i == 0):
            fl = False
            print(n, "is a composite number")
            break
        if i * i >= n:
            break
    if(fl and n != 1):
        print(n, "is a prime number")
    elif(n == 1):
        print(n, "is a composite number")
elif t == 17:
    a, b = map(int, input().split())
    resheto = [1 for i in range(0, b + 1)]
    resheto[1] = 0
    for i in (range(2, b + 1)):
        if(resheto[i] == 1):
            if( a <= i <= b):
                print(i, end=" ")
            for j in range(i + i, b + 1, i):
                resheto[j] = 0

elif(t == 18):
    n = int(input())
    s = 1
    for i in range(2, n):
        if(n % i == 0):
            s += i
            if(i * i != n):
                s += int(n / i)
            if s > n:
                break
        if (i+1) * (i+1) >= n:
            if((i+1) * (i+1) == n):
                s+= i + 1
            break
    if s == n:
        print("YES")
    else:
        print("NO")
Leave a Comment