-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab exe6.py
120 lines (82 loc) · 1.6 KB
/
lab exe6.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
# 1 to find sum using recursion
# def sum(piece):
# if len(piece) == 0:
# return 0
# else:
# return piece[0] + sum(piece[1:])
#
# print(sum([1, 3, 4, 2, 5]))
# 2 to display the multiplication of 3 uoto n
# def mul(number):
# if number == 1:
# return 3
# else:
# return 3 + mul(number - 1)
#
#
# print(mul(10))
# 3 to return sum of first n intiger
# def sum(n):
# if n <= 1:
# return n
# return n + sum(n - 1)
#
#
# n = 5
# print(sum(n))
# 4 to check if string is palindrome or not
# def isPalRec(st, s, e):
# if (s == e):
# return True
#
# if (st[s] !=st [e]):
# return False
#
#
# if (s < e + 1):
# return isPalRec(st, s + 1, e - 1)
#
# return True
#
# 5 to check if the number is palindrome or not
# def isPalindrome(st):
# n = len(st)
#
# if (n == 0):
# return True
#
# return isPalRec(st, 0, n - 1)
#
# st = "madam"
# if isPalindrome(st):
# print("The given string is palindrome")
# else :
# print("The given string is not palandrome")
# 6 to check if number is palindrome or not
#
# def isPalRec(st, s, e):
# if s == e:
# return True
#
# if st[s] != st[e]:
# return False
#
#
# if s < e + 1:
# return isPalRec(st, s + 1, e - 1)
#
# return True
#
#
# def isPalindrome(st):
# n = len(st)
#
# if n == 0:
# return True
#
# return isPalRec(st, 0, n - 1)
# num = int(input("enter a number"))
# if isPalindrome(str(num)):
# print("The number is palindrome")
# else:
# print("The number is palindrome")