Python Week 3
Python Week 3
n = int(input())
# Initialize variables
sum = 0
term_sum = 0
# Loop through the terms and add them to the running total
for i in range(1, n+1):
term_sum += i
sum += term_sum
GrPA2
n=int(input())
for b in range (2,n+1):
# first check if f is a factor of n
if n%b==0:
#now check if b is prime
is_prime = True
for i in range(2,b):
if b%i==0:
is_prime = False
break
if is_prime:
print(b)
GrPA 3
GrPA 4
string = input("")
GrPA 5
n = int(input())