Algorithm to find Lucky Numbers

前端 未结 10 979
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 21:02

I came across this question.A number is called lucky if the sum of its digits, as well as the sum of the squares of its digits is a prime number. How many numbers between A

10条回答
  •  梦毁少年i
    2020-12-22 22:09

    First I would like to add that a lucky number can be calculated by a sieve, the explanation of the sieve can be found here: http://en.wikipedia.org/wiki/Lucky_number

    so you can improve your solution speed using a sieve to determine the numbers,

提交回复
热议问题