How to count frequency of digits in a given number in java / Java program to count the number of times each digit occurs in a number

This problem is pretty common in interviews and computer examinations. Candidate is required to write a program where a user enters any random integer and the program should display the digits and their count in the number. For Example, if the entered number is 74526429492, then frequency of 7 is 1, 4 is 3, 5 is 1, 6 is 1, 2 is 3, 9 is 2. In tabular format,

(more…)

Continue Reading

How to check Pronic number in java / Program to check for Pronic number in java

What is a Pronic Number ?

A number which is the product of two consecutive numbers is a Pronic Number. Consecutive means the numbers which come one after other when counted in ascending order such as 2,3; 5,6; 98,99 and so on. Thus, a product of any two consecutive numbers is a Pronic number. Example, 12 is a product of 3 and 4 (consecutive numbers), thus it is a Pronic number. Other examples of Pronic numbers are 20 (product of 4 and 5), 42 (product of 6 and 7), 72 (product of 8 and 9) and so on.

(more…)

Continue Reading

How to convert decimal number to binary in java / Various ways to convert decimal number to binary in java

Overview

A binary number is a number which is composed of digits 1 and 0 such as 110011. A decimal number is a number which is composed of digits 0 to 9 such as 130672. It is a common requirement in computer programming to convert a binary number to decimal format and vice-versa. In this post, we will focus on different ways a decimal number can be converted to its equivalent binary number in java.

(more…)

Continue Reading
Close Menu