Jan Christian Grünhage
b7e9046bc6
This was the only (kind of) relevant file form an old github repo, I wont migrate the whole repo, especially, since keeping it in this repo makes way more sense.
67 lines
2.7 KiB
Java
67 lines
2.7 KiB
Java
package de.janchristiangruenhage.demo.math.multiplication;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.math.BigInteger;
|
|
|
|
/**
|
|
* Created by green on 12/8/2015.
|
|
*/
|
|
public class BWMathe {
|
|
public static void main(String[] args) {
|
|
Output out = null;
|
|
try {
|
|
out = new Output("bwmathe_1.txt");
|
|
} catch (FileNotFoundException e) {
|
|
e.printStackTrace();
|
|
}
|
|
// for (int i = 1; i < 2016; i++) {
|
|
// String multiplierOneString = "1";
|
|
// String multiplierTwoString = "1";
|
|
// for (int j = 0; j < i; j++) {
|
|
// multiplierOneString += "01";
|
|
// multiplierTwoString += "00";
|
|
// }
|
|
// multiplierTwoString += "01";
|
|
// BigInteger multiplierOneBigInt = new BigInteger(multiplierOneString);
|
|
// BigInteger multiplierTwoBigInt = new BigInteger(multiplierTwoString);
|
|
// BigInteger result = multiplierOneBigInt.multiply(multiplierTwoBigInt);
|
|
// String resultString = (result.toString());
|
|
// int numberOfInitialZeroes = ((resultString.length() - 1) / 2);
|
|
// for (int j = 0; j < i; j++) {
|
|
// multiplierTwoString += "00";
|
|
// }
|
|
// multiplierTwoString += "01";
|
|
// multiplierTwoBigInt = new BigInteger(multiplierTwoString);
|
|
// result = multiplierOneBigInt.multiply(multiplierTwoBigInt);
|
|
// resultString = (result.toString());
|
|
// int numberOfAdditiveZeroes = (((resultString.length() - 1) / 2) - numberOfInitialZeroes);
|
|
// if ((2016 - numberOfInitialZeroes) % numberOfAdditiveZeroes == 0) {
|
|
// out.println("Found a Solution: \n" +
|
|
// "Number is dividable by " + multiplierOneString + "\n" +
|
|
// "i = " + i);
|
|
// }
|
|
// }
|
|
//
|
|
String numberString = "1";
|
|
for (int i = 0; i < 2016; i++) {
|
|
numberString += "01";
|
|
}
|
|
BigInteger numberBigInt = new BigInteger(numberString);
|
|
// boolean isPrime = numberBigInt.isProbablePrime(500);
|
|
// out.println(new Boolean(isPrime).toString());
|
|
|
|
BigInteger divisor = new BigInteger("2");
|
|
while (true) {
|
|
if (numberBigInt.mod(divisor) == BigInteger.ZERO) {
|
|
out.println("Found a Solution: \n" +
|
|
"Number is dividable by " + divisor.toString() + "; \n" +
|
|
"Result is " +numberBigInt.divide(divisor) + "; ");
|
|
}
|
|
if (divisor.mod(new BigInteger("1000000")) == BigInteger.ZERO) {
|
|
System.out.println("Status update: " + divisor.toString());
|
|
}
|
|
divisor = divisor.add(BigInteger.ONE);
|
|
}
|
|
|
|
}
|
|
} |