Write a Python function threesquares(m) that takes an integer m as input and returns True if m can be expressed as the sum of three squares and False otherwise
Answers
Answered by
0
Answer:
def factors(n):
if n == 0:
return([0])
factorlist = []
for i in range(1,n+1):
if n%i == 0:
factorlist.append(i)
return(factorlist)
def square(n):
return(len(factors(n))%2 == 1)
def threesquares(n):
for i in range(0,n+1):
for j in range(i,n+1):
if square(i) and square(j) and square(n-(i+j)):
return(True)
return(False)
Explanation:
Similar questions
English,
5 months ago
Math,
5 months ago
Environmental Sciences,
10 months ago
Science,
10 months ago
CBSE BOARD X,
1 year ago