static List<int> nums = new List<int>(); public static bool IsHappy(int n) { int newint = 0; while (n != 0) { newint += ((n % 10) * (n % 10)); n = n / 10; } if (newint == 1) return true; if (nums.Contains(newint)) { return false; } else { nums.Add(newint); } return IsHappy(newint); }
LeetCode中Submission Result: Wrong Answer,
Input:13
Output:false
Expected:true
在Vs2010中能正常返回
时间: 2024-11-09 05:45:48