_3099

package
v0.0.0-...-5ea41ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 1 Imported by: 0

README

哈沙德数

如果一个整数能够被其各个数位上的数字之和整除,则称之为** 哈沙德数**(Harshad number)。给你一个整数 x 。如果 x 是 **哈沙德数 **,则返回__x 各个数位上的数字之和,否则,返回__-1

示例 1:

**输入:**x = 18

**输出:**9

解释:

x 各个数位上的数字之和为 918 能被 9 整除。因此 18 是哈沙德数,答案是 9

示例 2:

**输入:**x = 23

输出:-1

解释:

x 各个数位上的数字之和为 523 不能被 5 整除。因此 23 不是哈沙德数,答案是 -1

提示:

  • 1 <= x <= 100

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL