Skip to content

Instantly share code, notes, and snippets.

@andy23512
Created October 28, 2020 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy23512/942f22b976e8e6fda5ce866d1403a3f1 to your computer and use it in GitHub Desktop.
Save andy23512/942f22b976e8e6fda5ce866d1403a3f1 to your computer and use it in GitHub Desktop.
x = int(input("Enter the 1st even number x: "))
y = int(input("Enter the 1st even number y: "))
# for each even number between x and y
for i in range(x, y+1, 2):
print("The factor of", i, ": ", end="")
# for each number between 1 and i
for j in range(1, i+1):
# check if i can be divided by j
if (i % j == 0):
# j is a factor of i
print(j, end=" ")
print()
x = int(input("Enter a number x: "))
squ_sum = 0
n = 0
while (squ_sum < x):
n = n + 1
squ_sum = squ_sum + n ** 2
print("The smallest n is: ", n)
print("The sum of squares from 1 to n is:", squ_sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment