# Programmer: Sikder Huq and Sriram Pemmaraju # Date: Feb 16, 2014 # get input N = int(raw_input()) # Generate integers from 2 through N and test each integer for # abundance i = 2 while i <= N: # Code for testing if i is abundant # First we compute the sum of all factors of i, excluding itself factorSum = 0 factor = 1 # We only need to consider factors uptill i/2 because the only # factor of i larger than i/2 is i itself and this need not be # considered while factor <= i/2: if i % factor == 0: # test if factor evenly divides i factorSum = factorSum + factor # if so include factor in the sum factor = factor + 1 # generate the next candidate factor to test # i is abundant if its factor sum (excluding itself) is greater than it if factorSum > i: print i i = i + 1 # generate the next i to test for abundance