package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a ; System . out . println ( "Enter a number : " ); Scanner sc = new Scanner ( System . in ); a = sc . nextInt (); if ( a % 2 == 0 ) { System . out . println ( "Even number" ); } System . out . println ( "Odd number" ); } } Enter a number : 23 Odd number Process finished with exit code 0
Formulas for Divisibility Questions Formulas for Divisibility in Aptitude A divisibility is a rule for finding whether the number is divisible by another number or not. We can say that when number a is divided by another number b and remainder becomes zero . Hence the number a is divisible by b . It is away to find factors of a large numbers.In this Page Formulas for Divisibility is given. Formulas for Divisibility & Definitions: A divisibility rule is a shorthand method of determining whether a given number is divisible by a fixed divisor without carrying out the division, usually by examining its digits. One whole number is divisible by another if, after dividing, the remainder is zero. If the whole number is divisible by another number than the second number is factor of 1st number. Divisibility Formulas When we set up a division problem in an equation using our division algorithm, and r = 0, we have the following equation: a ...
Pallindrome Number : - If the reverse of the number is eqal to original number then , the number is pallindrome. ex:- original number = 121 , reverse number = = 121 therefore 121 is pallindrome. int r , n ; int rev = 0 ; Scanner sc = new Scanner( System . in ) ; n = sc .nextInt() ; int number = n ; // to not lost original number while ( n > 0 ) { r = n % 10 ; rev = rev * 10 + r ; n = n / 10 ; } System . out .println( rev ) ; if ( rev == number ) { System . out .println( "Number is pallindrome" ) ; } else System . out .println( "Number is not pallindrome" ) ; output :- 121 121 Number is pallindrome
Comments
Post a Comment