Posts

Showing posts from January, 2021

Smith Number in JAVA

Image
Smith Number in JAVA Smith Number : A Smith Number is a composite number, the sum of whose digits is the sum of the digits of its prime factors obtained as a result of Prime Factorization (excluding 1).   The first few Smith Numbers are : 4, 22, 27, 58, 85, 94, 121........ Etc. For Example :-   Input                                                            : 22 Sum of digits                                         : 2 + 2 = 4 Sum of digits of Prime Factors  : 2 + 2 = 4 Output                                          ...

Swap two Strings without using third variable

Image
Swapping of two Strings without using third variable in Java Swapping : Swapping simple means "Exchange". Swapping the values of two variables means exchanging the value of two variable with each other. For Example :- Input :- str1 = "Java" str2 = "Code"   Output after swapping :- str1 = "Code" str2 = "Java"

PigLatin Word in JAVA

Image
PigLatin Word in JAVA PigLatin Word : A Pig Latin word is obtained by framing a new word starting with the first vowel present in the word. The remaining letters before the first vowel will be added in the last followed by ' ay '. For Example :- Input           : "trouble" Output      : "oubletray"   Input           : "bluejcode" Output      : "uejcodeblay"

Kaprekar Number in JAVA

Image
Kaprekar Number in JAVA Kaprekar Number : A Kaprekar Number is a number whose square when divided into two parts and such that sum of parts is equal to the original number and none of the parts has value 0. Consider an n-digit number k . Square it and add the right n digits of the square to the left n or n-1 digits. If the resultant sum is equal to the number k, then k is called a Kaprekar Number. For Example :- Input           : 9 Square       : 81 Sum           : 8 + 1 = 9 Output      : It is a Kaprekar Number     Input           : 297 Square       : 88209 Sum           : 88 + 209 = 297 Output      : It is a Kaprekar Number  Input           : 10 Square       : 100 Sum ...