Affluent Savvy
Photo by cottonbro studio Pexels Logo Photo: cottonbro studio

What are spy numbers?

A number is said to be a Spy number if the sum of all the digits is equal to the product of all digits. Examples : Input : 1412. Output : Spy Number.

How long can u satisfy a woman?
How long can u satisfy a woman?

The average therapists' responses defined the ranges of intercourse activity times: "adequate," from three to seven minutes; "desirable," from...

Read More »
What is my spiritual gift?
What is my spiritual gift?

A spiritual gift is something God has chosen specifically for you so that you can help with the advancement of the church on earth by serving and...

Read More »
Awaken your dormant DNA ability to attract wealth effortlessly
Awaken your dormant DNA ability to attract wealth effortlessly

The simple yet scientifically proven Wealth DNA method laid out in the report allows you to effortlessly start attracting the wealth and abundance you deserve.

Learn More »

A number is said to be a Spy number if the sum of all the digits is equal to the product of all digits.

Examples :

Input : 1412

Output : Spy Number

Explanation :

sum = (1 + 4 + 1 + 2) = 8

product = (1 * 4 * 1 * 2) = 8

since, sum == product == 8 Input : 132

Output : Spy Number

Explanation :

sum = (1 + 3 + 2) = 6

product = (1 * 3 * 2) = 6

since, sum == product == 6

C++

#include using namespace std; bool checkSpy( int num) { int digit, sum = 0, product = 1; while (num > 0) { digit = num % 10; sum += digit; product *= digit; num = num / 10; } if (sum == product) return true ; else return false ; } int main() { int num = 1412; if (checkSpy(num)) cout << "The number is " << "a Spy number" << endl; else cout << "The number is " << "NOT a spy number" << endl; return 0; } Java import java.util.*; class GFG { static boolean checkSpy( int input) { int digit, sum = 0 , product = 1 ; while (input > 0 ) { digit = input % 10 ; sum += digit; product *= digit; input = input / 10 ; } if (sum == product) return true ; else return false ; } public static void main(String args[]) { int input = 1412 ; if (checkSpy(input)) System.out.println( "The number is " + "a Spy number" ); else System.out.println( "The number is " + "NOT a Spy number" ); } } Python3 def checkSpy(num): sums = 0 product = 1 while num> 0 : digit = num % 10 sums = sums + digit product = product * digit num = num / / 10 if sums = = product: return True else : return False num = 1412 if (checkSpy(num)): print ( "The number is a Spy Number" ) else : print ( "The number is NOT a spy number" ) C# using System; class GFG { static bool checkSpy( int input) { int digit, sum = 0, product = 1; while (input > 0) { digit = input % 10; sum += digit; product *= digit; input = input / 10; } if (sum == product) return true ; else return false ; } public static void Main() { int input = 1412; if (checkSpy(input)) Console.WriteLine( "The number is " + "a Spy number" ); else Console.WriteLine( "The number is " + "NOT a Spy number" ); } } PHP

How do I find my real superpower?
How do I find my real superpower?

5 Fun and Free Ways to Identify Your Superpowers Get curious about the people you admire. Try this: make a list of 5 people you admire. ... Start...

Read More »
What is the best bedtime snack?
What is the best bedtime snack?

Here are 14 excellent and healthy late-night snack ideas. Tart cherries. Consider adding tart cherries like Montmorency or their juice to your...

Read More »

0) { $digit = $num % 10; $sum += $digit ; $product *= $digit ; $num = $num / 10; } if ( $sum == $product ) return 1; else return -1; } $num = 1412; if (checkSpy( $num )) echo "The number is a " . "Spy number" , " " ; else echo "The number is NOT " . "a spy number" , "

" ; ?> Javascript

Output The number is a Spy number

Time Complexity: O(log 10 n)

Auxiliary Space: O(1)

This article is contributed by Chinmoy Lenka. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Should you wipe down your shower after every use?
Should you wipe down your shower after every use?

You only need to clean your shower and tub once a week, but if you have a glass shower door, it needs a little more attention. To prevent the build...

Read More »
What happens if you meditate too long?
What happens if you meditate too long?

Meditation lets you be in tune with your thoughts and emotions. And while this is generally a good thing, over-meditation can lead you to be...

Read More »
Awaken your dormant DNA ability to attract wealth effortlessly
Awaken your dormant DNA ability to attract wealth effortlessly

The simple yet scientifically proven Wealth DNA method laid out in the report allows you to effortlessly start attracting the wealth and abundance you deserve.

Learn More »
What is a scent everyone loves?
What is a scent everyone loves?

A study conducted by researchers from the Karolinska Institute in Sweden and the University of Oxford has found that vanilla is the world's most...

Read More »
Awaken your dormant DNA ability to attract wealth effortlessly
Awaken your dormant DNA ability to attract wealth effortlessly

The simple yet scientifically proven Wealth DNA method laid out in the report allows you to effortlessly start attracting the wealth and abundance you deserve.

Learn More »
What are some signs that death is near?
What are some signs that death is near?

What are the signs that someone is dying? feeling weak and tired. sleeping more or being drowsy. feeling hot or cold. cold hands or feet. eating...

Read More »