Python solution for the friend numbers cata