Simple Java Programs Odd Even Program in Java Sum of Odd & Even Numbers in Java Positive or Negative Number in Java Largest of Three Numbers in Java Swap Two Numbers in Java Divisible by 5 in Java Equal Program in Java Sum of Digits Program in Java Sum of Digits using Recursion in Java...
importjava.util.Scanner;classRecursionReverseDemo{//A method for reversepublicstaticvoidreverseMethod(intnumber){if(number<10){System.out.println(number);return;}else{System.out.print(number%10);//Method is calling itself: recursionreverseMethod(number/10);}}publicstaticvoidmain(Stringargs[]){intn...
Java - TreeSet Programs Java - StringJoiner Class Programs Java - HashMap Programs Java - Regular Expressions Programs Java - Tower of Hanoi Java - Binary Search Using Recursion Java - Read Boolean Value From File Java - Write Bytes Using ByteStream Java - Read Array Using ByteStream Java Pract...
Though both programs are technically correct, it is better to use for loop in this case. It's because the number of iteration (upto num) is known. Also Read: Java program to find factorial of a number using recursion Before we wrap up, let’s put your knowledge of Java Program to ...
In this section, we will learnhow to reverse a number in Javausingwhile loop,for loopandrecursion. To reverse a number, follow the steps given below: First, we find the remainder of the given number by using the modulo (%) operator. ...
Other Related Programs in c C program to shutdown or turn off computer Find power of a number using recursion using c program To find the maximum number within n given numbers using pointers To compute the average of n given numbers using pointers To check a number is prime or not using ...
Java Program to find the largest and smallest element in an array: Here is the Java program I am talking about. This shows you how to find the maximum and minimum number in a given array in Java, without using any library method. import java.util.Arrays; /** * Java program to find...
C program to convert a Binary number to Gray Code using Recursion C Digits Manipulation Programs C program to convert number from Decimal to Binary Advertisement Learn & Test Your Skills Python MCQsJava MCQsC++ MCQsC MCQsJavaScript MCQsCSS MCQsjQuery MCQsPHP MCQsASP.Net MCQs ...
How tocalculatefactorial using recursion and iteration? (solution) 10 Free Courses to learn Data Structure and Algorithms (courses) How to find duplicate characters from String in Java? (solution) How to find if given String is a palindrome in Java? (solution) ...
Java program for Fibonacci number using recursion. public static int fibonacciRecusion(int number) { if (number == 1 || number == 2) { return 1; } return fibonacciRecusion(number - 1) + fibonacciRecusion(number - 2); // tail recursion } // Method-2: Java program for Fibonacci numb...