3-digit Osiris number C Program?

An Osiris number is a special 3-digit number that equals the sum of all permutations of its 2-digit sub-samples. For example, 132 is an Osiris number because 12 + 21 + 13 + 31 + 23 + 32 = 132.

Syntax

bool isOsirisNumber(int n);

Algorithm

The approach is straightforward. For a 3-digit number, each digit appears exactly twice in the permutations − once in the tens position and once in the ones position. Therefore, we can check if the number equals 22 times the sum of its digits.

Begin
   a := last digit
   b := second digit  
   c := first digit
   digit_sum := a + b + c
   if n = (22 * digit_sum), then
      return true
   end if
   return false
End

Example

Here's a complete C program to check if a 3-digit number is an Osiris number −

#include <stdio.h>
#include <stdbool.h>

bool isOsirisNumber(int n) {
    int a = n % 10;           /* last digit */
    int b = (n / 10) % 10;    /* middle digit */
    int c = n / 100;          /* first digit */
    int sum = a + b + c;
    
    if (n == (22 * sum)) {
        return true;
    }
    return false;
}

int main() {
    int n = 132;
    
    printf("Testing number: %d
", n); if (isOsirisNumber(n)) printf("%d is an Osiris number
", n); else printf("%d is not an Osiris number
", n); return 0; }

Output

Testing number: 132
132 is an Osiris number

How It Works

For the number 132:

  • All 2-digit permutations: 12, 21, 13, 31, 23, 32
  • Sum: 12 + 21 + 13 + 31 + 23 + 32 = 132
  • Digit sum: 1 + 3 + 2 = 6
  • Check: 22 × 6 = 132 ?

Conclusion

An Osiris number can be efficiently checked by verifying if it equals 22 times the sum of its digits. This mathematical property eliminates the need to calculate all permutations manually.

Updated on: 2026-03-15T11:37:49+05:30

222 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements