You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
667 B
32 lines
667 B
def feb(n):
|
|
a = 1
|
|
b = 1
|
|
lis = []
|
|
while(a < n):
|
|
lis.append(a)
|
|
temp = a
|
|
a = b
|
|
b += temp
|
|
return lis
|
|
|
|
def get_prime(n):
|
|
primes = [True] * (n+1)
|
|
p = 2
|
|
while p ** 2 <= n:
|
|
if primes[p]:
|
|
for i in range(p * 2, n + 1, p):
|
|
primes[i] = False
|
|
p += 1
|
|
primes = [i for i in range(2, n) if primes[i]]
|
|
return primes
|
|
|
|
def is_palindrome(s):
|
|
for sep in range(0, len(s)//2):
|
|
if s[sep] != s[len(s) - sep - 1]:
|
|
return False
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
print(feb(1000))
|
|
print(get_prime(1000))
|
|
print(is_palindrome('aabbaa')) |