Extended Divisibility
sample input:
4 2
o/p:
4 2 2 1 1 1 1
Program in Python:
a,b=map(int,input().split())
x=a
z=b
k=[a]
while(x%b==0):
for j in range(z):
k.append(x//b)
z*=b
x=x//b
print(*k,sep=" ")
Extended Divisibility
sample input:
4 2
o/p:
4 2 2 1 1 1 1
Program in Python:
a,b=map(int,input().split())
x=a
z=b
k=[a]
while(x%b==0):
for j in range(z):
k.append(x//b)
z*=b
x=x//b
print(*k,sep=" ")
Post a Comment