Yahoo India Web Search

Search results

  1. 4 days ago · Approach 1: Firstly, consider the given number N as input. Then apply a for loop in order to iterate the numbers from 1 to N. At last, check if each number is a prime number and if it’s a prime number then print it using brute-force method. Java. class gfg { static void prime_N(int N) { int x, y, flg; System.out.println(

    • 5 min
  2. 4 days ago · Given two numbers a and b, the task is to find the GCD of the two numbers. Note: The GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. Examples: Input: a = 20, b = 28. Output: 4. Explanation: The factors of 20 are 1, 2, 4, 5, 10 and 20.

    • 9 min
  3. 4 days ago · Approach 1: Using Ternary operator. The syntax for the conditional operator: ans = (conditional expression) ? execute if true : execute if false. If the condition is true then execute the statement before the colon. If the condition is false then execute a statement after colon so. largest = z > (x>y ? x:y) ? z:((x>y) ? x:y); Illustration:

  4. 2 days ago · Frequently asked Java basic programs include Fibonacci series, prime numbers, factorial numbers, and palindrome numbers, among others. Each program is accompanied by multiple examples and their respective outputs.

  5. Jul 1, 2017 · Write a Java program to check if a given number is prime or not. Remember, a prime number is a number which is not divisible by any other number, e.g. 3, 5, 7, 11, 13, 17, etc. Be prepared for cross, e.g. checking till the square root of a number, etc. 3. String Palindrome ( solution)

    • missing numbers program in java1
    • missing numbers program in java2
    • missing numbers program in java3
    • missing numbers program in java4
  6. 3 days ago · This method uses the Integer.highestOneBit() function to check if the number is a power of 2. In the above code: We check if the number is greater than zero. We use the Integer.highestOneBit() method to get the highest bit of the number. We check if this highest one-bit is equal to the number itself. 5.

  7. 3 days ago · if (number>1) { if (number == 2) { isPrime = true; } else. { int i = 2; while (i<number) { if (number % i == 0) { isPrime = false; break; } i++; } else. isPrime = false; if (isPrime) System.out.println (number); startingNumber++; } view raw Program16.java hosted with by GitHub.