Posts

Increasing and Decreasing Number in Java

Image
Increasing and Decreasing Number in Java Question :   Write a program to check whether a number is Increasing Number or Decreasing Number? Increasing Number :  In an integer traversing from left to right if the current digit is greater than or equal to the previous digit, the number is known as increasing numbers. Ex : 23689 Decreasing Number :  In an integer traversing from left to right if the current digit is less than the previous digit, the number is known as decreasing numbers. Ex : 98632 Note  : A number which is neither increasing nor decreasing is Bouncy Number. * To understand the program clearly watch this video :  Increasing/Decreasing Number in Java

Krishnamurthy Number in Java

Image
  Krishnamurthy Number in Java Question :   Write a program to check whether a number is Krishnamurthy number or not? Krishnamurthy Number : A number whose sum of the factorial of digits is equal to the number itself. Examples :- 145 1! + 4! + 5! = (1 X 1) + (4 X 3 X 2 X 1) + (5 X 4 X 3 X 2 X 1) = 1 + 24 + 120 = 145 Output : It is a Krishnamurthy Number 55 5! + 5! = (5 X 4 X 3 X 2 X 1) + (5 X 4 X 3 X 2 X 1) = 120 + 120 = 240 Output : It is not a Krishnamurthy Number Note  : To understand the program clearly watch this video :   Krishnamurthy Number in Java

Bouncy Number in Java

Image
Bouncy  Number in Java Question :   Write a program to check whether a number is Bouncy Number or not? Bouncy Number : A positive integer that is neither in increasing nor decreasing number is called a bouncy number. In other words, A number whose digits are unsorted. Increasing Number : In an integer traversing from left to right if the current digit is greater than or equal to the previous digit, the number is known as increasing numbers. Ex : 23689 Decreasing Number : In an integer traversing from left to right if the current digit is less than the previous digit, the number is known as decreasing numbers. Ex : 98632 Example of Bouncy Number : 13174, 101, 15296 etc. Note : There is no Bouncy Number between 1 to 100. Note  : To understand the program clearly watch this video :  Bouncy Number in Java

Norm of a Number in Java

Image
Norm of a Number in Java Question :   Write a program to calculate Norm of a Number. Norm of a number is square root of sum of squares of all digits of the number. Example :- Input : 68             6 X 6 + 8 X 8 = 100 ;  Square root of 100 = 10 Output : Norm of 68 is 10. Logic  :- First input number. Copy the input number in another variable extract each digit of the number Store the sum of squares of the digit of the number in a variable say 's' Print the square root of the result. (i.e. square root of 's' ) Compile and run the program Note  : To understand the program clearly watch this video :  https://youtu.be/tXDl56akraE

Factorial Series in Java (Series #7)

Image
Factorial Series in Java Question :   Write a program to print the following series. S = 2! + (2! + 3!) - (2! + 3! + 5!) + (2! + 3! + 5! + 7!)......... n terms The above series is very easy to solve Logic  :- First input number of terms The nth term will contain 'n' number of terms (ex- if n = 2, then it will contain 2 terms i.e. (2! + 3!)) calculate the nth term by first finding the first 'n' number of prime numbers Now, calculate factorial of each prime number Add the factorials of all the prime numbers Now if the nth term is odd and not the first then it will be a negative term else it will be a positive term Store the result in the variable accordingly Print the result Note : To understand the program clearly watch this video :  https://youtu.be/CRX9zDJYY4U

Weird Number

Image
Weird Number in Java Question :   Write a program to accept a number and check whether it is  Weird  number or not. Weird Number  :  A Weird number is a natural number that is Abundant but not Semi-Perfect . In other words, the sum of the proper divisors (divisors including 1 but not itself) of the number is greater than the number, but no subset of those divisors sums to the number itself.  First few Weird Numbers : 70, 836, 4030, 5830, 7192, 7912, 9272, 10430, 10570, 10792, 10990, 11410, 11690 Abundant Number : A number ‘n’ is said to be Abundant Number if sum of all the proper divisors of the number is greater than the number ‘n’. Semi-Perfect Number : A Semi-Perfect number or Pseudo-Perfect number is a natural number n that is equal to the sum of all or some of its proper divisors. 

Semi Perfect/Pseudo Perfect Number

Image
Semi Perfect/Pseudo Perfect Number in JAVA Question :   Write a program to accept a number and check whether it is  Semi-Perfect number or not. Semi-Perfect Number  :  A Semi-Perfect number or Pseudo-Perfect number is a natural number n that is equal to the sum of all or some of its proper divisors.  A Semi-Perfect number that is equal to the sum of all its proper divisors is a perfect number. First few Semi-Perfect numbers are: 6, 12, 18, 20, 24, 28, 30, 36, 40 etc. Proper Divisors : Proper divisor is a positive divisor of a number, excluding itself. Example  :- Input : 6 Proper Divisors of 6 : 1, 2, 3 Sum of Proper Divisors : 1 + 2 + 3 = 6 Output : Semi-Perfect Number (Since sum of all the factors is equal to the number, it is also a Perfect Number). Input : 12 Proper Divisors of 12 : 1, 2, 3, 4, 6 Sum of Proper Divisors : 1 + 2 + 3 + 6 = 12 Output : Semi-Perfect Number