C#,奥西里斯数(Osiris Number)的算法与源代码

1 奥西里斯数(Osiris Number)

奥西里斯数(Osiris Number)是一个数字,

其值等于通过将其自身数字的所有排列相加而形成的所有数字的值之和。

计算结果:

2 源程序

using System;

namespace Legalsoft.Truffer.Algorithm

{

/// <summary>

/// 奥西里斯数(Osiris Number)是一个数字,

/// 其值等于通过将其自身数字的所有排列相加而形成的所有数字的值之和。

/// </summary>

public static partial class Number_Sequence

{

public static bool Osiris_Number(int n)

{

int a = n % 10;

int b = (n / 10) % 10;

int c = n / 100;

int digit_sum = a + b + c;

if (n == (2 * (digit_sum) * 11))

{

return true;

}

return false;

}

}

}


POWER BY TRUFFER.CN

3 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer.Algorithm
{
    /// <summary>
    /// 奥西里斯数(Osiris Number)是一个数字,
    /// 其值等于通过将其自身数字的所有排列相加而形成的所有数字的值之和。 
    /// </summary>
    public static partial class Number_Sequence
    {
        public static bool Osiris_Number(int n)
        {
            int a = n % 10;
            int b = (n / 10) % 10;
            int c = n / 100;
            int digit_sum = a + b + c;
            if (n == (2 * (digit_sum) * 11))
            {
                return true;
            }
            return false;
        }
    }
}
相关推荐
mmmmath_32 小时前
LeetCode.541.反转字符串II
数据结构·算法·leetcode
Navigator_Z3 小时前
LeetCode //MySQL - 1251. Average Selling Price
c语言·算法·leetcode
醇氧3 小时前
MySQL 8.0 系统表损坏与引擎转换故障排查实战
数据结构·算法
大熊背4 小时前
《Color constancy by characterization of illumination chromaticity》之色度色域最大化算法(二)
算法·白平衡·色度·色温
钓鱼的肝4 小时前
梳理(1-5)
c++·经验分享·笔记·算法·青少年编程
HZZD_HZZD4 小时前
CSDN_批发市场水电漏损归因算法LAM的原理与落地
嵌入式硬件·物联网·算法
Neil20135 小时前
ajax跨域请求
c#
唐青枫5 小时前
别把 Razor 当成几段 HTML:C#.NET Razor Pages、MVC 视图与实战详解
c#·.net
shirsl6 小时前
算法 Day 5 树 / 二叉树 + DFS
数据结构·python·算法