---
# System prepended metadata

title: 109#6

---

# 109#6
## 502. 乘積
```
def compute(x,y):
  return x*y
x=eval(input())
y=eval(input())
print(compute(x,y))
```
## 503. 連加計算
```
def compute(x,y):
  sum=0
  for i in range(x,y+1):
    sum=sum+i
  return sum

x=eval(input())
y=eval(input())
print(compute(x,y))
```
## 504. 次方計算
```
def compute(x,y):
  return pow(x,y)
x=eval(input())
y=eval(input())
print(compute(x,y))
```
## 507. 質數
```
def compute(x):
  s=0
  for i in [2,3,5,7,11,13,17]:
    if x/i==1:
      s=1
  return s

x=eval(input())
if compute(x)==1:
  print("Prime")
else:
  print("Not Prime")
```
## 510. 費氏數列
```
def compute(x):
  if x==0:
    return 0
  if x==1:
    return 1
  if x>=2:
    return compute(x-2)+compute(x-1)

x=eval(input())
for i in range(0,x):
  print(compute(i),"",end="")
```
## 函數回傳2個結果
```
def f(x,y):
  print(f"{x}+{y}=",x+y,sep="")
  print(f"{x}-{y}=",x-y,sep="")
x=eval(input())
y=eval(input())
f(x,y)
```
## 302.期中考分數
```
def compute(score):
  if score<0 or score>100:
    print("-1")
  elif score>=60:
    print(score+5)
  else:
    print(score+10)

score=eval(input())
compute(score)
```
## 304.判斷有幾個3的倍數
```
def compute(lst1):
  y=0
  for i in range(6):
    if lst1[i]%3==0:
      y=y+1
  return y

lst1=[]
for i in range(6):
  x=eval(input())
  lst1.append(x)
print(compute(lst1))
```
## 306.n階計算
```
def compute(x):
  if x==0:
    return 1
  if x>=1:
    return x*compute(x-1)
x=eval(input())
print(x,"!=",compute(x),sep="")
```
## 計算成績總和與平均
```
def sum(a,b,c,d,e):
  f=(a+b+c+d+e)/5
  print(f"total = {a+b+c+d+e}\naverage = {f}")
a=eval(input())
b=eval(input())
c=eval(input())
d=eval(input())
e=eval(input())
sum(a,b,c,d,e)
```
## 305.數值運算
```
def compute(index,x,y):
    if index==1:
        ans=x+y
    if index==2:
        ans=x*y
    return ans
x=eval(input())
index=eval(input())
y=eval(input())
print(compute(index,x,y))
```
## 506. 一元二次方程式
```
ans=0
ant=0
def compute(a,b,c):
    r=(b**2)-(4*a*c)
    if r<0 or a==0 or b==0 or c==0:
        return "Your equation has no root."
    else:
        ans=((b-b*2)+(r**0.5))/(2*a)
        ant=((b-b*2)-(r**0.5))/(2*a)
        if ans==ant:
           return str(ans)
        else:
           return str(ans)+", "+str(ant)

a=eval(input())
b=eval(input())
c=eval(input())
print(compute(a,b,c))
```