Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find 2¹⁰²⁴

How to find 2¹⁰²⁴
The answer is correct. its 309 digit answer!!
I didn’t found any datatype in java compatible with this range

I tried

long

having range

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

but still not found answer

>Solution :

Its easy..

it’s easy to find.. lets see..
Your answer is :
The answer is correct. its 309 digit answer!!

179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216

its java program is

import java.math.BigInteger;
import java.util.Scanner;

public class powerOfNumber {
    public static String findPower(int s){
        BigInteger b= BigInteger.valueOf(s);
        BigInteger num= BigInteger.valueOf(2);
        BigInteger product= BigInteger.valueOf(1);
        for (int i = 1; i <= b.intValue(); i++) {
            product=product.multiply(num);
        }
        return product.toString();
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s= sc.nextInt();
        System.out.println(findPower(s));
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading