Skip to main content

REMAINDER TRICKS


REMAINDER TRICKS



Before going into the remainder tricks, I would like to tell u about Euler number.
What is Euler number and how to find out the Euler number of any other number?
          Answer of above question is very simple..
          
             Euler number is total number of numbers of co-prime that exist less then that number.
              For example    6 
                                      So 1 and 5 are the only co-prime which exists less then 6.
                                     So Euler number for 6=2.

         How to find Euler number of big numbers?

           First find out the total number of factors of that number and apply the following formula.
           Suppose we have a number p which has 3 factors q,r,s.
            Now to find the Euler number of p we will apply this formula :
                               
                                            Euler number= p * ((q-1)/q) * ((r-1)/r) * ((s-1)/s).

 For example Euler number of 21:
                           Factors of 21=3*7
                          So Euler number= 21 * ((3-1)/3) * ((7-1)/7)
                                                   =21* (2/3) * (6/7)
                                                   =2*6=12.

  Now we can easily calculate the Euler Number of any number.


             To apply these Euler number concept in finding remainder we will take a question i.e
                      *     Find out the remainder in 2^50/9 ?
                       Sol :      First calculate Euler number of 9 .
                                           Factor of 9=3*3
                                           Only one number i.e 3
                                           Now apply the formula i.e 9*((3-1)/3)
                                                                               =9*(2/3)
                                                                               =6.
                       So Euler number of 9 is 6.

                    Given problem was 2^50/9.
                     Now divide the power portion i.e 50 by Euler number i.e 6 = 50/6
                                                                                                                =remainder will be 2
                      Now replace the power by remainder
                                           
                                                  2^50/9
                                                =2^2/9
                                                =4/9
                                                = Remainder of it will be 4 answer
                                    



Popular posts from this blog

OOPS Concept in Java : POLYMORPHISM

 POLYMORPHISM IN JAVA :  Polymorphism means mutiple forms of Single reference. And to understand in simple way just take an example from my previous post of OOPS CONCEPT IN JAVA : INHERITANCE  , I request you guys to go through this link before proceding here. So in this post I have created a method called sum() in PARENT class which has been used by CHILD class without writing same sum() method in CHILD class. This was possible becuase of INHERITANCE concept in java.  But what if CHILD class is not satisfied with PARENT sum() and CHILD class wants to improve it like by adding some message before the calculation. To do this we have another OOPS CONCEPT IN JAVA i.e POLYMORPHISM and by applying this logic we can make same sum() method behvae differently based on Object. As I mentioned earlier POLYMORPHISM means different forms and same has been achieved here by calling same sum() method but the output is different based on Object on which it has been called. If ...

Java Program : Writing First Java Factorial Program with explanation

 NAMING CONVENTION IN JAVA : Java is an object oriented programming language , we can relate it to real life object like i mapped Java with human in my previous post JAVA OVERVIEW (SESSION 1)  and represent human properties like body parts as properties in Java and Human can dance , drive , walk , run these can be mapped as Behaviour in java.    Now To represent properties and behaviour in java , there are some standard naming conventions we should follow. Class name should always starts with Uppercase letter like class Student { //Code to be executed } Properties or any kind of variables should starts from lower case and afterwards every first letter of each next word should be in Upper case . like class Student { int studentId ; String studentName ; //Code to be executed } Methods name should also starts from lower case and afterwards every first letter of each next word should be in Upper case . like class Student { int studentId ; Str...

JAVA 8 FUNTIONAL INTERFACE

JAVA 8 FUNTIONAL INTERFACE  Funtional Interface :     An interface which has only one abstract method can be called a funtional interface. Comparable , Runnable , Callable all these interfaces has only one abstract method and can be consider as funtional interface.    How it works :        Once we will create a interface with one abstract method then java internally predicates the input type and based on the Interface reference it apply the logic mentioned after lambda expression    lets consider we have created an interface as below @FunctionalInterface public interface FuntionalExample { public int cal ( int a , int b) ; } And below class to test our funtional Interface. public class FuntionalInterfaceExample { public static void main (String args[]) { FuntionalExample addition=( int a , int b) -> a+b ; FuntionalExample subtraction=( int a , int b) -> a-b ; FuntionalExample multipl...