giveuponkhan

This commit is contained in:
Zach S-B 2021-11-05 16:58:22 +11:00
parent 4a8846dfe9
commit a0ee0db03b

View File

@ -30,41 +30,32 @@ public class Q2Tools {
{ {
String bInBinary = Integer.toBinaryString(B); String bInBinary = Integer.toBinaryString(B);
int test = 0; double test = 1;
System.out.println(bInBinary);
{
int k = 0; int k = 0;
//Loop through the Binary String, starting from the right
for(int i = bInBinary.length()-1; i >= 0; i--) for(int i = bInBinary.length()-1; i >= 0; i--)
{ {
if(bInBinary.charAt(i)=='1') if(bInBinary.charAt(i)=='1')
{ {
double temp = Math.pow(2, k); System.out.println("Loop: "+k);
System.out.println(2+"^"+k+"="+temp); double step1 = Math.pow(2, k);
test += temp; System.out.println("STEP1: "+step1);
}
else double step2 = Math.pow(A, step1)%C;
{ System.out.println("STEP2: "+step2);
System.out.println(0+"^"+k+"=0"); test= test*step2;
} }
k++; k++;
} }
}
System.out.println(test); System.out.println(test);
}
/** System.out.println(Math.pow(5, 64)%19);
* Simply wrapper for Integer.toBinaryString
* @param number integer to be converted to binary
* @return binary of number as an Biginteger
*/
public BigInteger convertToBinaryBigInt(int number)
{
//Take input number, convert to binary string
String binaryString = Integer.toBinaryString(number);
BigInteger bigBinary = new BigInteger(binaryString);
return bigBinary;
} }
} }