Learn practical skills, build real-world projects, and advance your career
Updated 2 years ago
#If nums is equal pair number in num_list return 'Pass'
def checksum(num_list, nums):
for i in range(len(num_list)):
for j in range(i+1, len(num_list)):
if num_list[i]+num_list[j] == nums:
return('Pass')
return('False')
checksum([9, -3, 7, 15, 3], 1)
'False'
## If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
## The sum of these multiples is 23.
## Find the sum of all the multiples of 3 or 5 below 1000.
sum = 0
for i in range(1,1000):
if((i % 3 == 0 ) or (i % 5 == 0)):
sum+=i
print(sum)
233168
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
max = 4000000
i = 1
sum = 0
while(sum<10):