# Write a python function to calcuate the easter date using Gauss's Algorithm

## Topic: Write a python function to calcuate the easter date using Gauss's Algorithm

Solution

``` def gaussEaster(Y):
A = Y % 19
B = Y % 4
C = Y % 7
P = int(Y / 100)
Q = int((13 + 8 * P) / 25)
M = (15 - Q + P - P // 4) % 30
N = (4 + P - P // 4) % 7
D = (19 * A + M) % 30
E = (2 * B + 4 * C + 6 * D + N) % 7
days = (22 + D + E)
if ((D == 29) and (E == 6)):
print(Y, "-04-19")
return
elif ((D == 28) and (E == 6)):
print(Y, "-04-18")
return
else:
if (days > 31):
print(Y, "-04-", (days - 31))
return
else:
print(Y, "-03-", days)
return
#write a python function to print the pascal's triangle

def printPascal(n):

for line in range(1, n + 1):
C = 1;
for i in range(1, line + 1):
print(C, end = " ");
C = int(C * (line - i) / i);
print("");
#write a python function to print Hosoya's triangle of height 'n'
def printHosoya(n):
dp = [[0 for i in range(n)]
for i in range(n)]

dp[0][0] = dp[1][0] = dp[1][1] = 1
for i in range(2, n):
for j in range(n):
if (i > j):
dp[i][j] = (dp[i - 1][j] +
dp[i - 2][j])
else:
dp[i][j] = (dp[i - 1][j - 1] +
dp[i - 2][j - 2])
for i in range(n):
for j in range(i + 1):
print(dp[i][j], end = ' ')
print()

#write a python function to print Floyd's triangle

def loydTriangle(n):
val = 1
for i in range(1, n + 1):

for j in range(1, i + 1):
print(val, end = " ")
val += 1
print("")

#write a python function to print reverese Floyd's triangle

def printReverseFloyd(n):

curr_val = int(n*(n + 1)/2)
for i in range(n + 1, 1, -1):
for j in range(i, 1, -1):
print(curr_val, end ="  ")
curr_val -= 1
print("")

# write a python function to print fibonacci series in the reverse order

def reverseFibonacci(n):

a = [0] * n
a[0] = 0
a[1] = 1
for i in range(2, n):
a[i] = a[i - 2] + a[i - 1]
for i in range(n - 1, -1 , -1):
print(a[i],end=" ")

# write a python function to print Leibniz Harmonic triangle

def LeibnizHarmonicTriangle(n):
C = [[0 for x in range(n + 1)]
for y in range(n + 1)];
for i in range(0, n + 1):
for j in range(0, min(i, n) + 1):
if (j == 0 or j == i):
C[i][j] = 1;
else:
C[i][j] = (C[i - 1][j - 1] +
C[i - 1][j]);
for i in range(1, n + 1):
for j in range(1, i + 1):
print("1/", end = "");
print(i * C[i - 1][j - 1],
end = " ");
print();
# write a python function to check whether the given series is in Arithematic progression

def checkIsAP(arr, n):
if (n == 1): return True
arr.sort()
d = arr[1] - arr[0]
for i in range(2, n):
if (arr[i] - arr[i-1] != d):
return False

return True

# write a python function to check whether the given series is in harmonic progression

def is_geometric(li):
if len(li) <= 1:
return True
ratio = li[1]/float(li[0])
for i in range(1, len(li)):
if li[i]/float(li[i-1]) != ratio:
return False
return True
# write a python function to find the area of a circumscribed circle of an equilateral triangle

def area_cicumscribed(a):
return (a * a * (3.14159265 / 3))

# write a python function to find the side of a octogon inscribed in a square

def octaside(a):
if a < 0:
return -1
s = a / (1.414 + 1)
return s

# write a python program to find the area of enneagon

length = 6
Nonagon_area = 6.1818 * (length ** 2)
print("Area of regular Nonagon is = ", Nonagon_area)

# write a python function to find the day of the week given the date

def dayofweek(d, m, y):
t = [ 0, 3, 2, 5, 0, 3,
5, 1, 4, 6, 2, 4 ]
y -= m < 3
return (( y + int(y / 4) - int(y / 100)
+ int(y / 400) + t[m - 1] + d) % 7)

# write a python function to calculate the MDAS factorial of a number

def MDAS_Factorial( N ):
if N <= 2:
return N
if N <= 4:
return N + 3
if (N - 4) % 4 == 0:
return N + 1
elif (N - 4) % 4 <= 2:
return N + 2
else:
return N - 1

# write a python function to find the nth pronic number

def findRectNum(n):
return n*(n + 1)

#write a python function to find the sum of N pronic numbers
def calculateSum(N):

return (N * (N - 1) // 2 +
N * (N - 1) * (2 *
N - 1) // 6);

#write a python function to find the sum of first N even numbers

def evensum(n):
curr = 2
sum = 0
i = 1
while i <= n:
sum += curr
curr += 2
i = i + 1
return sum

# write a python function to check whether a number can be written as a sum of 3 primes (Goldbach Weak Coonjecture)

def check(n):
if n % 2 == 1 and n > 5:
print('YES')
else:
print('NO')
# write a python function to find the nth perrin number

def per(n):

if (n == 0):
return 3;
if (n == 1):
return 0;
if (n == 2):
return 2;
return per(n - 2) + per(n - 3);

# write a python function to find the betrothed numbers smaller than n

def BetrothedNumbers(n) :

for num1 in range (1,n) :
sum1 = 1
i = 2
while i * i <= num1 :
if (num1 % i == 0) :
sum1 = sum1 + i
if (i * i != num1) :
sum1 += num1 / i
i =i + 1
if (sum1 > num1) :

num2 = sum1 - 1
sum2 = 1
j = 2
while j * j <= num2 :
if (num2 % j == 0) :
sum2 += j
if (j * j != num2) :
sum2 += num2 / j
j = j + 1
if (sum2 == num1+1) :
print ('('+str(num1)+', '+str(num2)+')')

# write a python function to implement linear extrapolation

def extrapolate(d, x):
y = (d[0][1] + (x - d[0][0]) /
(d[1][0] - d[0][0]) *
(d[1][1] - d[0][1]));
return y;
# write a python function to print the collatz sequence

def printCollatz(n):
while n != 1:
print(n, end = ' ')
if n & 1:
n = 3 * n + 1
else:
n = n // 2
print(n)

# write a python function to print the newman-conway sequence

def sequence(n):
f = [0, 1, 1]
print(f[1], end=" "),
print(f[2], end=" "),
for i in range(3,n+1):
f.append( f[f[i - 1]] + f[i - f[i - 1]])
print(f[i], end=" "),

#write a python function to find the nth term in a padovan's sequence
pPrevPrev, pPrev, pCurr, pNext = 1, 1, 1, 1
for i in range(3, n+1):
pNext = pPrevPrev + pPrev
pPrevPrev = pPrev
pPrev = pCurr
pCurr = pNext

return pNext;

# write a python function to print the raceman sequence

def recaman(n):
arr = [0] * n
arr[0] = 0
print(arr[0], end=", ")
for i in range(1, n):
curr = arr[i-1] - i
for j in range(0, i):
if ((arr[j] == curr) or curr < 0):
curr = arr[i-1] + i
break
arr[i] = curr
print(arr[i], end=", ")
# write a python function to print the sylvester's sequence

def printSequence(n) :
a = 1
ans = 2
N = 1000000007
i = 1
while i <= n :
print ans,
ans = ((a % N) * (ans % N)) % N
a = ans
ans = (ans + 1) % N
i = i + 1

# write a python function to find the sum of two numbers without using arithematic operators

while (y != 0):
carry = x & y
x = x ^ y
y = carry << 1
return x

# write a python function to subtract two numbers without using arithemmatic operators

def subtract(x, y):
while (y != 0):
borrow = (~x) & y
x = x ^ y
y = borrow << 1

return x
# write a python function to find the smallest number to be subtracted from a given number to make the given number palindrome

def minSub(N):
count = 0
while (N >= 0):
num = N
rev = 0
while (num != 0):
digit = num % 10
rev = (rev * 10) + digit
num = num // 10
if (N == rev):
break
count += 1
N -= 1
print(count)

# write a python function to check whether the number is a perfect square without finding square root

def isPerfectSquare(n) :
i = 1
while(i * i<= n):
if ((n % i == 0) and (n / i == i)):
return True
i = i + 1
return False

# write a python function to find the square root of a number using babylonian method

def squareRoot(n):
x = n
y = 1
e = 0.000001
while(x - y > e):

x = (x + y)/2
y = n / x

return x

```