From b7e9046bc6057c86876dea280353e0159e9e067f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Tue, 15 Nov 2016 11:50:50 +0000 Subject: [PATCH] Add 'src/de/janchristiangruenhage/demo/math/multiplication/BWMathe.java' 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. --- .../demo/math/multiplication/BWMathe.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/de/janchristiangruenhage/demo/math/multiplication/BWMathe.java diff --git a/src/de/janchristiangruenhage/demo/math/multiplication/BWMathe.java b/src/de/janchristiangruenhage/demo/math/multiplication/BWMathe.java new file mode 100644 index 0000000..69260b7 --- /dev/null +++ b/src/de/janchristiangruenhage/demo/math/multiplication/BWMathe.java @@ -0,0 +1,67 @@ +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); + } + + } +} \ No newline at end of file