 Amicable numbers | Sololearn: Learn to code for FREE!

0

# Amicable numbers

I have came across the concept amicable numbers while reading a book and i wanted to write a code to find one in the range from 1 to 500 and due to me not coding for a while i used if statement and for loop because they are basic concepts that are easy to remember ,and i was able to find the numbers by checking the results , my question is how can i alter on / improve the code so that it will be able to find amicable numbers and return them in the result https://code.sololearn.com/cSqzLyxXqNWU/?ref=app

+2

dareen moughrabi https://code.sololearn.com/cXfdw3JI1vHs/?ref=app

+2

dareen moughrabi continue is used to skip current iteration So if the sum of factor is equal to the number then we are avoiding to check factor of that new sum sum is a sum of factors of i sum1 is a sum of factors of sum So if i and sum1 are same means 220 and sum of factor of 284(sum of factor of i (220)) then printing that numbers.

+1

A͢J thx for attempting to help I have run the code and it almost works perfectly yet there are additional results which do not work as amicable numbers The sum of the factors of 28 Is 28 And the sum of the factors of 6 is 6 And 496 is 496

+1

dareen moughrabi So that should be avoid to print?

+1

dareen moughrabi Now check again

+1

I understood it thx for the help A͢J