Previous
0 / 33
Module DEMO-32-60DEMO-C-32

Find Strong Numbers in a Range

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

In this challenge, you will write a program to find and print all Strong numbers within a given range.

What is a Strong Number?

A Strong number is a number where the sum of the factorials of its digits equals the number itself.

For example:

  • 145 is a Strong number because: 1! + 4! + 5! = 1 + 24 + 120 = 145
  • 2 is a Strong number because: 2! = 2

Task

Given two integers A and B, print all Strong numbers in the range [A, B] (inclusive), in increasing order, separated by spaces.

You must use nested loops to solve this problem.

Constraints

You must use nested loops in your solution. The range will not exceed 10000. The output must be in increasing order.

Input Format

A single line containing two space-separated integers A and B:

  • $1 \leq A \leq B \leq 10000$

Output Format

Print all Strong numbers between A and B (inclusive), separated by spaces.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
1 200
1 2 145
Input: 1 200
Sample #2
Public sample
1 10
1 2
Input: 1 10
Sample #3
Public sample
1 5
1 2
Input: 1 5
Sample #4
Public sample
1 2
1 2
Input: 1 2

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings