Showing posts with label Divisors Of N. Show all posts
Showing posts with label Divisors Of N. Show all posts

Saturday, July 2, 2022

Divisors Of N

 Divisors Of N 

Problem Statement
Given an integer N, the task is to find the number of divisors of N which are divisible by 2.

import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
    public static void main (String[] args) {
              
              Scanner inputTaker = new Scanner(System.in);
              int u = inputTaker.nextInt();
              while(u>0){
                  int n= inputTaker.nextInt();
                  int count=0;
                  for(int x= 1; x<=Math.sqrt(n); x++){
                       
                    if(n%x== 0){

                        if(x%2 == 0){
                            count++;
                        }
                        if(x*!= n){
                            if((n/x)%2== 0) {
                                count++;
                            }
                        }
                    }
               }
               System.out.println(count);
               u--;
              }
    }
}

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...