mod wanko algorithm