![]() |
In this article, we will look at a Duck Number in Java. We will look at its meaning and rules for a number to be Duck Number with the help of examples and write a Java program to demonstrate and verify it through our code. What is Duck Number?A Duck Number is a positive non-zero number containing at least one zero in its numeric representation. The zero should be present as a leading zero, i.e. the digit zero can be present at any position except at the start of the number. Rules for a number to be a Duck Number
Examples of Duck NumbersLet us look at some examples of Duck numbers to understand the concept better:
Approach:
Program to check whether a given number is a Duck Number or notBelow is the Java program to check whether the given number is a Duck Number or not. Java
Output
Given number 0012740 is not a Duck Number Given number 11005 is a Duck Number Explanation of the above Program:
Complexity of the above Program:
D is the total number of digits in the number |
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |