How can I calculate modulo of a large number in String format in java

Question!

I am trying to calculate an expression in java which is in String i.e 99999999999999999^99999999999999999 I want to calculate this number modulo 1000000007. I currently trying to store the big numbers as double but taking modulo with double gives me NaN. Can somebody help ?

By : piyush121


Answers

You can use BigInteger and modPow(BigInteger, BigInteger) like

BigInteger m = new BigInteger("1000000007");
BigInteger a = new BigInteger("99999999999999999");
BigInteger b = new BigInteger("99999999999999999");
BigInteger answer = a.modPow(b, m);
System.out.println(answer);

which gives

265859324


EXAPMPLE SOLUTION is here on jsbin

You can change your CSS

.item { width: calc(19% - 10px); }

or

.item { width: calc(20% - 14px); }

By : Yar HTUT


If I am reading this correctly, Message would contain a List<MessageUser>.

If that's the case then this should get you close:

var List<Message> messages = 
    ( from m 
      in db.Messages 
      where 
          m.UserID == userid || m.MessageUsers.Any(mu => mu.UserID == userID) 
      select m).ToList();
By : Sam Axe


This video can help you solving your question :)
By: admin