PHP on Silex ugly numbers solution