美文网首页
202、happy number

202、happy number

作者: BeijingIamback | 来源:发表于2016-03-25 15:37 被阅读26次

    Write an algorithm to determine if a number is "happy".

    A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

    代码:

    相关文章

      网友评论

          本文标题:202、happy number

          本文链接:https://www.haomeiwen.com/subject/klqdlttx.html