For a positive integer n, let bess(n) be the sum of the divisors of n with n itself left out. For example bess(12)=1+2+3+4+6=16, and continuing from there, bess(16)=1+2+4+8=15, bess(15)=1+3+5=9, bess(9)=1+3=4, bess(4)=1+2=3, and bess(3)=1. By definition bess(1)=0.
Start at a positive integer x and follow the values x, bess(x), bess(bess(x)) and so on. If x ever comes back, the values listed in order up to the step just before the return form the chain of x. Since bess(6)=1+2+3=6, the chain of 6 is the single element 6. Since bess(220)=284 and bess(284)=220, the chain of 220 is 220 284. Longer chains exist too.
You are given two integers start and end. Find every chain whose first element lies between start and end, inclusive. Report a chain only when its first element is the smallest element of that chain. If any other element of the chain is smaller than the first element, the chain is not reported.
If a value larger than 2,000,000 shows up while you follow the values, treat that starting point as producing no chain. A value in the middle of a chain may exceed end. No chain has more than 50 elements.