Posts

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 ...

Twin Prime Number Using Function in JAVA

Image
Twin Prime Number using Function in JAVA Twin Prime Number : A Twin Prime is a prime number that is either 2 less or 2 more than another prime number— For example, ( 41 , 43 ) are twin pairs. In other words, a twin prime is a prime that has a prime gap of two . Algorithm to check whether two numbers are Twin prime or not :- Input two numbers Check both the numbers are prime or not Check if the difference between the numbers is equal to 2 or not If both the numbers are prime and difference is equal to 2 Print "Numbers are Twin Prime" Else print "Numbers are not Twin Prime"

Fibonacci Prime Series in JAVA

Image
Fibonacci Prime Series Fibonacci Series : A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 0, 1, 1, 2, 3, 5, 8, etc.   Fibonacci Prime Series : A Fibonacci prime is a Fibonacci number that is prime, a type of integer sequence prime.   The first few terms of the sequence are :-   2, 3, 5, 13, 89, 233, 1597, 28657, 514229, 433494437, 2971215073, ....

Tribonacci Series in JAVA

Image
Tribonacci Series Tribonacci Series : A Tribonacci sequence is a sequence of numbers such that each term from the fourth onward is the sum of the previous three terms. It is similar to Fibonacci Series   The first few terms of the sequence are :-   0, 0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927