# Determine whether the given integer N is a Peculiar Number or not

Given an integer N, our task is the determine if the integer N is Peculiar Number. If it is then print “yes” otherwise output “no”.

The peculiar number is the number which is three times the sum of digits of the number.

Examples:

Input: N = 27
Output: Yes
Explanation:
Digit sum for 27 is 9 and 3 * 9 = 27 which is equal to N. Hence the output is yes.

Input: N = 36
Output: No
Explanation:
Digit sum for 36 is 9 and 3 * 9 = 27 which is not equal to N. Hence the output is no.

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach:

To solve the problem mentioned above we have to first find the sum of the digits of a number N. Then check if the sum of digits of the number multiplied by 3 is actually the number N itself. If it is then print Yes otherwise the output is no.

Below is the implementation of the above approach:

## C++

 `// C++ implementation to check if the ` `// number is peculiar ` ` `  `#include ` `using` `namespace` `std; ` ` `  `// Function to find sum of digits ` `// of a number ` `int` `sumDig(``int` `n) ` `{ ` `    ``int` `s = 0; ` ` `  `    ``while` `(n != 0) { ` `        ``s = s + (n % 10); ` ` `  `        ``n = n / 10; ` `    ``} ` ` `  `    ``return` `s; ` `} ` ` `  `// Function to check if the  ` `// number is peculiar ` `bool` `Pec(``int` `n) ` `{ ` `    ``// Store a duplicate of n ` `    ``int` `dup = n; ` ` `  `    ``int` `dig = sumDig(n); ` ` `  `    ``if` `(dig * 3 == dup) ` `        ``return` `true``; ` ` `  `    ``else` `        ``return` `false``; ` `} ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``int` `n = 36; ` ` `  `    ``if` `(Pec(n) == ``true``) ` `        ``cout << ``"Yes"` `<< endl; ` ` `  `    ``else` `        ``cout << ``"No"` `<< endl; ` ` `  `    ``return` `0; ` `} `

## Java

 `// Java implementation to check if the ` `// number is peculiar ` `import` `java.io.*; ` ` `  `class` `GFG{ ` ` `  `// Function to find sum of digits ` `// of a number ` `static` `int` `sumDig(``int` `n) ` `{ ` `    ``int` `s = ``0``; ` ` `  `    ``while` `(n != ``0``) ` `    ``{ ` `        ``s = s + (n % ``10``); ` `        ``n = n / ``10``; ` `    ``} ` `    ``return` `s; ` `} ` ` `  `// Function to check if number is peculiar ` `static` `boolean` `Pec(``int` `n) ` `{ ` `     `  `    ``// Store a duplicate of n ` `    ``int` `dup = n; ` `    ``int` `dig = sumDig(n); ` ` `  `    ``if` `(dig * ``3` `== dup) ` `        ``return` `true``; ` `    ``else` `        ``return` `false``; ` `} ` ` `  `// Driver code ` `public` `static` `void` `main (String[] args)  ` `{ ` `    ``int` `n = ``36``; ` ` `  `    ``if` `(Pec(n) == ``true``) ` `        ``System.out.println(``"Yes"``); ` `    ``else` `        ``System.out.println(``"No"``); ` `} ` `} ` ` `  `// This code is contributed by shubhamsingh10 `

## Python3

 `# Python3 implementation to check if the ` `# number is peculiar ` ` `  `# Function to get sum of digits ` `# of a number  ` `def` `sumDig(n): ` `     `  `    ``s ``=` `0` `    ``while` `(n !``=` `0``):  ` `        ``s ``=` `s ``+` `int``(n ``%` `10``)  ` `        ``n ``=` `int``(n ``/` `10``)  ` `     `  `    ``return` `s ` `     `  `# Function to check if the   ` `# number is peculiar      ` `def` `Pec(n): ` `     `  `    ``dup ``=` `n ` `    ``dig ``=` `sumDig(n) ` ` `  `    ``if``(dig ``*` `3` `=``=` `dup): ` `        ``return` `"Yes"` `    ``else` `: ` `        ``return` `"No"` `         `  `# Driver code  ` `n ``=` `36` ` `  `if` `Pec(n) ``=``=` `True``: ` `    ``print``(``"Yes"``) ` `else``: ` `    ``print``(``"No"``) ` ` `  `# This code is contributed by grand_master `

## C#

 `// C# implementation to check if the ` `// number is peculiar ` `using` `System; ` ` `  `class` `GFG{ ` ` `  `// Function to find sum of digits ` `// of a number ` `static` `int` `sumDig(``int` `n) ` `{ ` `    ``int` `s = 0; ` ` `  `    ``while` `(n != 0) ` `    ``{ ` `        ``s = s + (n % 10); ` `        ``n = n / 10; ` `    ``} ` `    ``return` `s; ` `} ` ` `  `// Function to check if the number is peculiar ` `static` `bool` `Pec(``int` `n) ` `{ ` `     `  `    ``// Store a duplicate of n ` `    ``int` `dup = n; ` `    ``int` `dig = sumDig(n); ` ` `  `    ``if` `(dig * 3 == dup) ` `        ``return` `true``; ` `    ``else` `        ``return` `false``; ` `} ` ` `  `// Driver code ` `public` `static` `void` `Main()  ` `{ ` `    ``int` `n = 36; ` ` `  `    ``if` `(Pec(n) == ``true``) ` `        ``Console.Write(``"Yes"``); ` `    ``else` `        ``Console.Write(``"No"``); ` `} ` `} ` ` `  `// This code is contributed by Akanksha_Rai `

Output:

```No
```

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.