Table of Contents
Algorithm
Example
Output
Home Backend Development C++ C program for Osiris numbers with 3 digits?

C program for Osiris numbers with 3 digits?

Aug 26, 2023 am 08:05 AM
number c program osiris

C program for Osiris numbers with 3 digits?

Here we will see the Osiris. The number of Osiris is a number that is equal to the sum of permutations of subsamples of its own number. Suppose this number is 132, then if we calculate {12 21 13 31 23 32}, this is also 132. So this number is the number of Osiris. We have to check if the given number is the number of Osiris.

The method is very simple. If we analyze these numbers, each number appears twice, so they are in the ones and tens places. So we can check that by multiplying them by 11.

Algorithm

isOsirisNumber(n) -

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

#include
using namespace std;
bool isOsirisNumber(int n) {
   int a = n % 10;
   int b = (n / 10) % 10;
   int c = n / 100;
   int sum = a + b + c;
   if (n == (22 * sum)) {
      return true;
   }
   return false;
}
int main() {
   int n = 132;
   if (isOsirisNumber(n))
      cout << "This is Osiris number";
   else
      cout << "This is Not Osiris number";
}

Output

This is Osiris number

The above is the detailed content of C program for Osiris numbers with 3 digits?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

C program uses rename() function to change file name C program uses rename() function to change file name Sep 21, 2023 pm 10:01 PM

The rename function changes a file or directory from its old name to its new name. This operation is similar to the move operation. So we can also use this rename function to move files. This function exists in the stdio.h library header file. The syntax of the rename function is as follows: intrename(constchar*oldname,constchar*newname); The function of the rename() function accepts two parameters. One is oldname and the other is newname. Both parameters are pointers to constant characters that define the old and new names of the file. Returns zero if the file was renamed successfully; otherwise, returns a nonzero integer. During a rename operation

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument Sep 17, 2023 am 10:49 AM

Hyperbolic functions are defined using hyperbolas instead of circles and are equivalent to ordinary trigonometric functions. It returns the ratio parameter in the hyperbolic sine function from the supplied angle in radians. But do the opposite, or in other words. If we want to calculate an angle from a hyperbolic sine, we need an inverse hyperbolic trigonometric operation like the hyperbolic inverse sine operation. This course will demonstrate how to use the hyperbolic inverse sine (asinh) function in C++ to calculate angles using the hyperbolic sine value in radians. The hyperbolic arcsine operation follows the following formula -$$\mathrm{sinh^{-1}x\:=\:In(x\:+\:\sqrt{x^2\:+\:1})}, Where\:In\:is\:natural logarithm\:(log_e\:k)

C program to implement Euclidean algorithm C program to implement Euclidean algorithm Sep 17, 2023 pm 12:41 PM

The problem implements Euclidean's algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers and outputs the results with a given integer. Solution The solution to implement Euclidean algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers is as follows - the logic of finding GCD and LCM is as follows - if (firstno*secondno!=0){ gcd= gcd_rec(firstno,secondno); printf("TheGCDof%dand%dis%d",

Realme GT Neo6 is scheduled to be released on May 9th! The first AI digital human conference in the computer industry Realme GT Neo6 is scheduled to be released on May 9th! The first AI digital human conference in the computer industry May 08, 2024 pm 12:49 PM

On May 7, our mobile phone manufacturer officially announced that our company’s GTNeo6 launch conference is scheduled for May 9. GTNoe6 is positioned as a "performance storm", aiming to stir up the mid-range machine situation. In addition, this conference will also be the first AI digital human conference in the mobile phone industry. At that time, Realme Vice President, Global Marketing President, and China President Xu Qi will appear at the press conference in the form of a digital human. Digital man Xu Qi According to the official introduction, Realme GTNoe6, codenamed "Hurricane", is faster and stronger. It will challenge the strongest third-generation Snapdragon 8s flagship and the strongest product in its class. Recently, the Realme GTNeo6 was found to be directly on the e-commerce platform. Some core configurations were exposed, showing that the machine is not only equipped with a Snapdragon 8s processor, but also supports 120W flash charging.

C program to check if date is valid C program to check if date is valid Sep 20, 2023 am 10:17 AM

The given date format is day, month and year (integer). The task is to determine if that date is feasible. Valid date range should be 1/1/1800–31/12/9999, dates outside these dates are invalid. These dates include not only the year range, but also all constraints related to calendar dates. The constraints are - the date cannot be less than 1 and greater than 31. The month cannot be less than 1 and greater than 12. The year cannot be less than 1800 and greater than 9999. When the month is April, June, September, or November, the date cannot exceed 30. When the month is February, we have to check if, if the year is a leap year then the number of days cannot exceed 29 days otherwise the number of days cannot exceed 28 days. li>If all constraints are true, then it is a valid date, else it is not

Methods and applications of judging the number of digits in PHP Methods and applications of judging the number of digits in PHP Mar 27, 2024 pm 08:21 PM

PHP is a popular server-side scripting language that is widely used to develop web applications. In web development, we often encounter situations where we need to determine the number of digits in a number. This article will introduce the method and application of PHP to determine the number of digits in a number, and provide specific code examples. 1. Methods for judging the number of digits in a number. In PHP, judging the number of digits in a number can be achieved through a variety of methods. The following are some commonly used methods: Use the built-in function strlen(): you can directly convert the number into a string, and then Use strlen() function

C program of Rabin-Karp algorithm for pattern search C program of Rabin-Karp algorithm for pattern search Sep 17, 2023 am 09:01 AM

Pattern Matching in C - We have to find if a string exists in another string, for example, the string "algorithm" exists in the string "naivealgorithm". If it is found, then its location (i.e. where it is located) is displayed. We tend to create a function that takes an array of 2 characters and returns the position if it matches -1 otherwise. Input:txt="HEREISANICECAP" pattern="NICE"Output:Patternfoundatindex10Input:tx

How to convert string to number in Golang How to convert string to number in Golang Jan 16, 2024 am 08:20 AM

How to convert strings to numbers in Golang In Golang, we often need to convert strings to numbers to perform some calculation operations. The process of converting strings to numbers is relatively simple and mainly relies on the strconv package in the Golang standard library. This article will introduce in detail how to use the strconv package to convert strings to numbers and give some specific code examples. Converting a string to an integer To convert a string to an integer, you can use the Atoi function from the strconv package. Ato

See all articles