Famous algorithm in php