Week 2.2

 avatar
unknown
python
2 years ago
812 B
5
Indexable
TASK 2

k = int(input())
i = 1
sum = 0
while i < (k+1):
    sum += i**2
    i+=1
print(sum)
TASK 4
n,yes=int(input()),True
if n==2: print('prime')
for i in range(2,int(n**0.5)+2):
  if n%i==0:
    yes=False
    break
if yes:
    print('prime')
else:
    print('composite')
TASK 6
f=[0,1]
n=int(input())
yes=True
for i in range(998):
    f.append(f[i]+f[i+1])
if n==0 or n==1: 
    print(n)
else:
  for i in range(3,1000):
    if f[i]==n:
      print(i); yes=False; break
  if yes: print('no')
TASK 8
list = []
a = input()
while a != '.':
    list.append(int(a))
    a = input()
print(sum(list))
TASK 10
list = []
a = input()
while a != '.':
    list.append((float(a))**2)
    a = input()
print(sum(list))
TASK 12
list = []
a = input()
while a != '.':
    list.append((float(a)))
    a = input()
print(max(list))
Editor is loading...