Created
October 28, 2020 15:30
-
-
Save andy23512/942f22b976e8e6fda5ce866d1403a3f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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