- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
3-digit Osiris number in C?
Osiris Number is a number whose value is equal to the sum of values of all number formed by adding all the permutations of its own digits.
In this problem, we are given a 3-Digit number N, and we will check weather the number N is an Osiris number.
Let’s take an example,
Input : N = 132 Output : 132
Explanation
All sub-samples of N : 13 , 12, 21, 23 ,32 31.
Sum = 13+12+21+23+32+31 = 132
To do this, we have a formula to check whether the given number is Osiris number or not.
Example
#include <stdio.h> int main() { int n = 132; 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)) { printf("%d is an Osiris number",n); } else printf("%d is not an Osiris number",n); return 0; }
Output
132 is an Osiris number
Advertisements