Skip to content

Instantly share code, notes, and snippets.

View Svastikkka's full-sized avatar
🏛️
Working in Bengaluru

Manshu Sharma Svastikkka

🏛️
Working in Bengaluru
View GitHub Profile
## Read input as specified in the question.
## Print output as specified in the question.
num=int(input())
count=1
for i in range(1,num+1):
for j in range(0,i):
print(i+j,end="")
print()
## Read input as specified in the question.
## Print output as specified in the question.
num=int(input())
count=num
for i in range(1,num+1):
while count>1:
print(" ",end="")
count=count-1
for j in range(0,i):
print(i+j,end="")
## Read input as specified in the question.
## Print output as specified in the question.
num=int(input())
i=1
while num>=i:
spaces=1
while spaces<=(num-i):
print(" ",end="")
spaces=spaces+1
k=i
## Read input as specified in the question.
## Print output as specified in the question.
FibArray = [1, 1]
def fibonacci(n):
if n < 0:
print("Incorrect input")
elif n <= len(FibArray):
return FibArray[n - 1]
l=int(input())
p=2 #set the starting node
prime = [True for i in range(l + 1)] #create a prime list and make all elements set to TRUE
prime[0] = False
prime[1] = False
while p*p <=l:
if prime[p]==True:
for i in range(p*2,l+1,p):
prime[i]=False
def printTable(start,end,step):
#Implement Your Code Here
while True:
c=0
if start<=end:
c=(start-32)*5/9
print(start,int(c))
start = start + step
else:break
import math
def isPerfectSquare(x):
s = int(math.sqrt(x))
return s * s == x
def isFibonacci(n):
return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)
"""
Getting Prime Number using SieveOfEratosthenes
"""
l=int(input())
p=2 #set the starting node
prime = [True for i in range(l + 1)] #create a prime list and make all elements set to TRUE
prime[0] = False
prime[1] = False
while p*p <=l:
if prime[p]==True:
def merge(a1,a2,a):
i=0
j=0
k=0
while i<len(a1) and j<len(a2):
if a1[i]<a2[j]:
a[k]=a1[i]
k=k+1
i=i+1
else:
def partion(a,si,ei):
pivot=a[si]
c=0 #count number of elements which are greater than initial pi[si]
# below loop use to count the number of elements are greater than initial pi
for i in range(si,ei+1):
if a[i]<pivot:
c=c+1
a[si+c],a[si]=a[si],a[si+c] #swap
pivot_index=si+c