145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included.
Besedilo naloge
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included.
Opis problema in ideja rešitve
Poiskati moramo vsoto vseh številk, ki so enaki vsoti fakultete svojih številk,. Najprej poiščtemo vsa števila, ki jih nakoncu še seštejemo in dobimo vsoto. Na spletni strani: www.blog.dreamshire.com/2009/04/08/project-euler-problem-34-solution najdemo, da je zgornja meja 9!*7=2540160, do tukaj se nam splača števila pregledovati. Za spodnjo mejo pa vzamemo 10, ker ena sama številka se ne upošteva.
Razlaga algoritma
Testni program