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. Swift 学习笔记十五:扩展

    扩展就是向一个已有的类.结构体或枚举类型加入新功能(functionality).扩展和 Objective-C 中的分类(categories)相似.(只是与Objective-C不同的是,Swif ...

  2. C#:消息队列应用程序

    Carl NolanMicrosoft Corporation 摘要:本文概述一种用于处理若干消息队列的 Windows 服务解决方案,重点介绍 .NET 框架和 C# 应用程序. 下载 CSharp ...

  3. nexus7 升级失败后手动刷系统

    http://bbs.gfan.com/android-6934570-1-1.html   步骤如下: 1. 下载Android系统文件,打开官方地址:https://developers.goog ...

  4. centos6 安装GitLab

    环境 Requirements 软件 版本CentOS 6.6Python 2.6Ruby 2.1.5Git 1.7.10+Redis 2.0+MySQL GitLab 7-8-stableGitLa ...

  5. bzoj 4484 [Jsoi2015]最小表示——bitset

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4484 每个点上存一下它到每个点的连通性.用 bitset 的话空间就是 \( \frac{n ...

  6. 共享设置及ftp设置

    第一部分 共享设置 一.添加编译选项 network---file transfer---aria2                                                   ...

  7. 【python】序列切片和range函数

    序列的每个元素都可以用2种索引的表达方式,一种是正数索引,另一种是负数索引. 序列切片,作用是访问序列中一定范围的元素,格式“序列名[A:B]”,其中A为所切片的第一个元素的索引号,而B为切片后剩下的 ...

  8. jquery select radio

    Query获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...});   //为S ...

  9. Javascript之类型检测(一)

    js中有7种内置类型,这7种类型又分为2大类:基本数据类型和对象(object) 一.检测原始(基本数据:字符串.数字.布尔.null.undefined.symbol)类型. 用typeof检测原始 ...

  10. 提取数据之goose使用

    1.简介 Python-goose项目是用Python重写的Goose,Goose原来是用Java写的文章提取工具.Python-goose的目标是给定任意资讯文章或者任意文章类的网页,不仅提取出文章 ...