-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignement1.py
85 lines (74 loc) · 1.65 KB
/
Assignement1.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def gcd(a,b):
if b>a:
if a==0:
return b
else:
return gcd(b%a,a)
else:
if b==0:
return a
else:
return gcd(a%b,b)
def lcm(x, y):
# selecting the greater number
if x > y:
greater = x
else:
greater = y
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
def Factorial(n):
if n==1:
return 1
else:
return n*Factorial(n-1)
def Power(a,n):
if n==0:
return 1
else:
return a * Power(a,n-1)
def one(a,n):
result = (Power(a,Factorial(n))-n)%gcd(a,n)
return result
def two(a,b):
if lcm(a,b)%gcd(a,b)==0:
return True
else:
return False
def three():
if Power(5,9)%31 == 6:
return True
else:
return False
def four(n):
sum = 0
for i in range(1,n):
sum += i**3
# print(sum)
if sum%n==0:
return True
else:
return False
print("First Question")
a = int(input("Enter the number for question 1 : "))
n = int(input("Enter the power for question 1 : "))
print(one(a,n))
print("Second Question")
num1 = int(input("Enter the number 1 for question 2 : "))
num2 = int(input("Enter the number 2 for question 2 : "))
if two(num1,num2)==True:
print("Its Verified")
else:
print("Not Verified")
print("Third Question")
print(three())
print("Fourth Question")
num = int(input("Enter the number for question 4 : "))
if four(num)==True:
print("Its Verified")
else:
print("Not Verified")