public class Solution {
public int AddDigits(int num) {
var str = num.ToString(); int result = ; foreach (var c in str)
{
result += Convert.ToInt32(c.ToString());
} if (result >= )
{
result = AddDigits(result);
} return result;
}
}

https://leetcode.com/problems/add-digits/#/description

leetcode258的更多相关文章

  1. LeetCode258:Add Digits

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  2. [LeetCode258] Add Digits 非负整数各位相加

    题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one di ...

  3. [Swift]LeetCode258. 各位相加 | Add Digits

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  4. LeetCode258 各位相加

    题目链接:https://leetcode-cn.com/problems/add-digits/ 给定一个非负整数 num,反复将各个位上的数字相加,直到结果为一位数. 示例: 输入: 38 输出: ...

  5. LeetCode258——Add Digits

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  6. LeetCode172 Factorial Trailing Zeroes. LeetCode258 Add Digits. LeetCode268 Missing Number

    数学题 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. N ...

  7. LeetCode 258

    Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...

  8. k进制正整数的对k-1取余与按位取余

    华电北风吹 天津大学认知计算与应用重点实验室 日期:2015/8/24 先说一下结论 有k进制数abcd,有abcd%(k−1)=(a+b+c+d)%(k−1) 这是由于kn=((k−1)+1)n=∑ ...

  9. LeetCode 258. 各位相加(Add Digits)

    258. 各位相加 258. Add Digits 题目描述 给定一个非负整数 num,反复将各个位上的数字相加,直到结果为一位数. LeetCode258. Add Digits 示例: 输入: 3 ...

随机推荐

  1. 线程池、及使用场景、线程安全封装、ConcurrentHashMap应用场景

    https://blog.csdn.net/sinbadfreedom/article/details/80467253  :1.HashMap与ConcurrentHashMap的区别与应用场景 h ...

  2. [团队项目]SCRUM项目6.0 7.0

    6.0----------------------------------------------------- sprint演示 1.坚持所有的sprint都结束于演示. 团队的成果得到认可,会感觉 ...

  3. WPF中使用BitmapImage处理图片文件(转)

    (1)图片从文件导入 BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri(filen ...

  4. Xamarin版的C# SVG路径解析器

    原文:Xamarin版的C# SVG路径解析器 Xamarin版的C# SVG路径解析器,对SVG的Path路径进行解析,其中包括: 主程序SvgPathParser.cs, 相关接口定义:ISour ...

  5. [转]Maven中profile和filtering实现多个环境下的属性过滤

    背景 项目构建的时候,需要根据不同的场景来改变项目中的属性资源,最为常见的莫过于数据库连接配置了,试想有生产环境.测试缓存.发布环境等,需要为不同的场景下来动态的改变数据库的连接配置.而使用maven ...

  6. weex 知识点

    使用 weex init [project_name] 创建的项目,执行 npm run dev 后,在 public/dist 文件夹里面就生成了两个对应的js,一个是index.web.js, 一 ...

  7. WinRAR打包时不包含文件夹本身,只打包文件夹里的文件和目录

    加上-ep1 参数即可. rar u -m3 -s -r -o+ -ep1 -x*.zip client_zmv9.zip ".\client_zmv9\*"

  8. linux 信号处理 五 (示例)

    [摘要]本文分析了Linux内核对于信号的实现机制和应用层的相关处理.首先介绍了软中断信号的本质及信号的两种不同分类方法尤其是不可靠信号的原理.接着分析了内核对于信号的处理流程包括信号的触发/注册/执 ...

  9. Mysql 性能优化1 硬件设备的选择

    --------------------------------------------目录------------------------------------------------- • 我们 ...

  10. 关于Java高并发的问题

    前言: 对于我们开发的网站,如果网站的访问量非常大的话,那么我们就需要考虑相关的并发访问问题了.而并发问题是绝大部分的程序员头疼的问题, 为了更好的理解并发和同步,我们需要先明白两个重要的概念:同步和 ...