write a program in java to display the following pattern
12345
2345
345
45
5
Answers
Answered by
0
Answer:
https://onlinegdb.com/HkZ8QelbW8
Explanation:
here is the code on this link. you can also run it.
https://onlinegdb.com/HkZ8QelbW8
public class Main
{
public static void main (String[]args)
{
int startingNumber = 12345;
int divisor = 10000; // this contains number of zero equal to number
//of digits in original number
while (startingNumber != 0)
{
System.out.println (startingNumber);
startingNumber = startingNumber % divisor;
divisor = divisor / 10;
}
}
}
Similar questions