-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepinsta_L1.py
209 lines (208 loc) · 4.12 KB
/
prepinsta_L1.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#pos or neg no
""" x=int(input())
if x>0:print(True)
else:print(False) """
#sum of natural no
""" sum=0
for i in range(int(input())+1):
sum+=i
print(sum) """
#greatest of 3
""" x,y,z=map(int,input().split(' '))
if z > max(x,y):print(z)
else:print(max(x,y)) """
#leap year
""" x=int(input())
if x%4==0:
if x%100==0:
if x%400==0:
print('yes',x)
else:
print('NO')
else:
print('NO')
else:
print('NO') """
#prime no
""" x=int(input())
c=0
for i in range(2,x//2):
if x%i==0:
c+=1
if c==0:print('prime')
# prime in range
s=int(input())
e=int(input())
for i in range(s,e+1):
for j in range(2,i//2):
if i%j ==0:
break
else:print('prime no is',i)"""
#Sum of digit of no
""" x=int(input())
sum=0
while(x>0):
t=x%10
sum=sum+int(t)
x=x//10
print(sum) """
#reverse no
""" x=input()
l=[int(i) for i in str(x)]
l=l[::-1]
print(int("".join(map(str,l)))) """
#palnidrome
""" x=input()
l=[int(i) for i in str(x)]
l=l[::-1]
t=int("".join(map(str,l)))
if int(x)==t:print('Palnidrome') """
#Amstrong
""" import math
x=int(input())
sum,d=0,0
t2=x
while(t2>0):
t2=t2//10
d+=1
t2=x
while (t2>0):
t=t2%10
sum=sum+math.pow(t,d)
t2=t2//10
print(sum,x)
if x==int(sum):print('Amstrong') """
#fibonacci 0 1 1 2 3 5 8
""" x=int(input())
s,n=0,1
print(s,n,end='')
for i in range(2,x):
t=n+s
s=n
n=t
print('',t,end=' ') """
#optimized
""" def fibonacciSeries(i):
if i <= 1:
return i
else:
return (fibonacciSeries(i - 1) + fibonacciSeries(i - 2))
if num <= 0:
print("Please enter a Positive Number")
else:
print("Fibonacci Series:", end=" ")
for i in range(num):
print(fibonacciSeries(i), end=" ") """
#factotial
""" def fact(n):
if n==1 or n==0:
return 1
else :
return n*fact(n-1)
n=int(input())
print(fact(n))
"""
#power of no
""" x,n=map(int,input().split(' '))
t=x
for i in range(n-1):
t=t*x
print(t) """
#factor of no
""" n=int(input())
print('1',end=' ')
for i in range(2,n//2+1):
if n%i==0:
print(i,end=' ')
print(n) """
#strong no
""" def fact(n):
if n==1 or n==0:
return 1
else :
return n*fact(n-1)
n=int(input())
sum,n1=0,n
while(n1>0):
t=n1%10
sum=sum+fact(t)
n1=n1//10
if sum==n:print('Estrong') """
#optimal
""" temp=n
sum=0
f=[0]*10
f[0]=1
f[1]=1
for i in range(2,10): #precomputing the factorial value from 0 to 9 and store in the array.
f[i]=f[i-1]*i
#Implementation
while(temp):
r=temp%10 #r will have the vale u of the unit digit
temp=temp//10
sum+=f[r] #adding all the factorial
if(sum==n):print(‘Yes’, n ,‘is strong number’)
else:print(‘No’ , n, ‘is not a strong number’) """
#perfect sq
""" n=int(input())
import math
x=math.pow(n,0.5)
if x%1==0.0:print('Square') """
# perfect no
""" n=int(input())
sum=0
for i in range(1,n):
if n%i==0:
sum=sum+i
if sum==n:print('perfect no') """
#automorphic no
""" n=int(input())
import math
x=int(math.pow(n,2))
x=str(x)
n=str(n)
x1=''
for i in range(len(n)):
x1=x1+x[ len(x)-len(n)+i ]
print(i,x1)
print(x1)
if x1==str(n):print('Automorphic') """
#optimized
""" print(‘Enter the number:’)
n=int(input())
sq=n*n #square of the given number
co=0 #condition variable
while(n>0): #loop until n becomes 0
if(n%10!=sq%10):
print(‘Not Automorphic’)
co=1
break
n=n//10
sq=sq//10
if(co==0):
print(‘Automorphic’) """
#hashed no
""" n=int(input())
x= sum(map(int, str(n)))
print(n,x,n%x)
if n%x==0:print('Hashed') """
#abundant no
"""
n=int(input())
s=0
for i in range(1,n//2+1):
if n%i==0:
s+=i
if s>n:print('Abdudant') """
#friendly pair
""" x,y=map(int,input().split(' '))
s1=0
for i in range(1,x+1):
if x%i==0:
s1+=i
s2=0
for i in range(1,y+1):
if y%i==0:
s2+=i
print(s1,s2)
if s1/x == s2/y :print('friendly') """