Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First attempt at problem 91. no idea why this is failing.

  • Loading branch information...
commit 58b20ae061a830c1bc13eb7899680aec348792de 1 parent 9b6d23a
@agargiulo authored
Showing with 42 additions and 0 deletions.
  1. +42 −0 src/Problem091.java
View
42 src/Problem091.java
@@ -0,0 +1,42 @@
+import java.math.BigInteger;
+
+/**
+ * File: Problem091.java
+ * Date created: Apr 6, 2012
+ *
+ * @author Anthony Gargiulo
+ */
+
+/**
+ * @author Anthony Gargiulo
+ * @version 0.1
+ *
+ * The first known prime found to exceed one million digits was
+ * discovered in 1999, and is a Mersenne prime of the form
+ * (2^6972593)-1; it contains exactly 2,098,960 digits. Subsequently
+ * other Mersenne primes, of the form (2^p)-1, have been found which
+ * contain more digits.
+ *
+ * However, in 2004 there was found a massive non-Mersenne prime which
+ * contains 2,357,207 digits: 28433×(2^7830457)+1.
+ *
+ * Find the last ten digits of this prime number.
+ *
+ */
+public class Problem091
+{
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ BigInteger number = BigInteger.valueOf(2L);
+ number.pow(7830457);
+ number.multiply(BigInteger.valueOf(28433L));
+ number.add(BigInteger.valueOf(1L));
+ String result = number.toString();
+ System.out.println(result.substring(result.length() - 11));
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.