sandeshMC

Tutorial 8 - Program

Apr 5th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public class HelloWorld {
  2.     public static void main(String[] args) {
  3.         long premod = 1;
  4.         long mod = 0;
  5.         int i = 0;
  6.         while (i<9721) {
  7.             mod = ((long)Math.pow(3, 127))%100000;
  8.             premod = mod*premod;
  9.             i++;
  10.         }
  11.         System.out.println("premod is : "+premod);
  12.         System.out.println("solution is : "+premod%100000);
  13.         String s = Long.toString(premod);
  14.         System.out.print("The last five digits are \t");
  15.         for(int j = s.length()-5 ; j<s.length() ; j ++)
  16.             System.out.print(s.charAt(j));
  17.     }
  18.  
  19. }
  20.  
  21. /*
  22. OUTPUT :
  23. premod is : 8520365264649205535
  24. solution is : 5535
  25. The last five digits are    05535
  26.  */
Advertisement
Add Comment
Please, Sign In to add comment