We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Number Theory
  4. Identify Smith Numbers

Identify Smith Numbers

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

A Smith number is a composite number, the sum of whose digits is the sum of the digits of its prime factors obtained as a result of prime factorization (excluding ). The first few such numbers are , , , , , , and .

Example:

So, its prime factors are , , , , and .
The sum of its digits is .
The sum of the digits of its factors is .

Similarly, is a Smith number.
, and the sum of its digits is the same as the sum of the digits of its prime factors: .

Task:
Write a program to check whether a given integer is a Smith number.

Input Format

There will be only one line of input: , the number which needs to be checked.

Constraints:
(max value of an integer of the size of bytes)

Output Format

if the number is a Smith number.
if the number is a not Smith number.

Sample Input

378

Sample Output

1

Explanation

Its prime factors are , , , , and .
The sum of its digits is .
The sum of the digits of its factors is .

Author

PRASHANTB1984

Difficulty

Easy

Max Score

20

Submitted By

9029

Need Help?


View discussions
View editorial
View top submissions
RESOURCES

  • Divisors

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy