# Tag Info

## Hot answers tagged number-theory

Accepted

### Find the 5566th digit after the decimal point of 7/101

Fast algorithm n = 5566 IntegerPart[10 Mod[7 PowerMod[10, n - 1, 101], 101]/101] A brute force approach (see also these posts on stackoverflow :) ) may be fine ...
• 19.3k
Accepted

### InverseTotient[ ]?

Perhaps: ReduceEulerPhiInverse[6] (* {7, 9, 14, 18} *) Not sure why such things are hidden & undocumented, perhaps because it's available through ...
• 241k

### Transform a number to a factorial

An example target, a bit over half-a-million digits: x = 123456!; IntegerLength@x 574965 Results for target, and a non-hit: ...
• 25.9k
Accepted

### How to calculate $\prod\limits_{p}\frac{p^2+1}{p^2-1}$?

A Trace reveals the problem: ...
• 241k

### Digits of Pi in colored spiral

At first we define the Archimedean spiral in parametric form a := 0; b := 0.3; r[t_] := a + b t; x[t_] := r[t]*Cos[t]; y[t_] := r[t]*Sin[t]; Next, generate a list ...
• 19.3k
Accepted

### SquaresR memory leak?

Cause Under the hood SystemSquaresR is still calling functions in the context NumberTheory. Partial output of: ...
• 273k

### Determining if a number is divisible by 1000

Use Divisible: Divisible[a, 1000] False
• 399k

### François Viète's approximation to π

You could use VietePiApprox[n_] := (Times @@ NestList[Sqrt[2 + #] &, Sqrt[2], n])/ 2^(n + 1) SetAttributes[VietePiApprox, Listable] which approximates Pi as ...
• 15.3k

### Does Mathematica have a twin prime equivalent of PrimePi`?

If you need all the primes that are twin primes up to n then. ...
• 37k

### How can I plot a Farey diagram?

The curvilinear triangles which are characteristic for this type of plot are called hypocycloid curves. We can use the parametric equations on Wikipedia to plot these, like so: ...
• 71k

### Transform a number to a factorial

Stirling's approximation, $n! \sim n^ne^{-n}$, is the Swiss army knife of factorial problems. If $x = n!$, this implies that $\ln x \sim n \ln n - n$; and surprisingly this can be solved with a ...
• 15.3k
Accepted

### Fastest square number test

Here's an idea similar to Carl Woll's that's a little faster: ...
• 241k

### Finding vampire numbers

Consider the trusty DivisorPair function from MrWizard: ...
• 15.3k
Accepted

### Making the number 12345...n

FromDigits@Flatten[IntegerDigits /@ Range[15]] 123456789101112131415 A function to do it: ...
• 12k
Accepted

### Elliptic curve cryptography in Mathematica

A few updates, since Wolfram has added a lot of cryptography functionality in recent versions. Here is a link to the guide page for Cryptography functions in the Wolfram Language: https://reference....
• 9,831
Accepted

### Factor a polynomial Root into Roots of smallest possible degree

A constructive approach The problem can be solved if the form of the solution is given. Define the two factors using a hint (that these should be cubic equations) in the original post ...
• 19.3k
Accepted

### Plotting the sum of two points on an elliptic curve

Here's a starting point: ...

### Calculate $140$ digits of Conway's Constant from the Look and Say Sequence

I call this ambiguous and I think you haven't thought this through. Let us assume it would be possible by such a direct method of calculating $\lambda$. First, we need to speed up the high-level ...
• 113k
Accepted

### Zeckendorf representation

Here's a greedy algorithm, using results from here: ...
Accepted

### Drawing a sequence of circles

Graphics[ {r = Length[Divisors@#]/2; ColorData["Rainbow"][(r - 1)/7], Circle[{#, 0}, r]} & /@ Range[150], ImageSize -> 504]
• 161k
Accepted

### Sum a number's digits until only one digit remain

Clear[s, t, n] t[n_] := NestWhileList[Total[IntegerDigits[#]] & , n, # > 10 &] Test: t[649134976] {649134976, 49,...
• 56.2k
Accepted

### Checking if a number is right sorted

f1 = OrderedQ @* Rest @* IntegerDigits; f1 /@ {51369, 51396} {True, False} ...
• 399k

### Some information about PrimeQ function

Source: https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.html PrimeQ first tests for divisibility using small primes, then uses the Miller–Rabin strong ...
• 5,470

### First two n such that $1355297$ divides$10^{6n+5}-54n-46$ for $n>0$

There is no need for a brute force search. There is also no need for compilation, which may run into the maximum compiled integer limit. A faster solution follows from a bit of theory. You can get the ...
• 15.3k
Accepted

### Computing the seven roots of a polynomial

poly = x^7 + x^6 - 18 x^5 - 35 x^4 + 38 x^3 + 104 x^2 + 7 x - 49; Find an extension in which the polynomial splits: ...
• 241k
Accepted

### Mathematica code for computing the $p$-adic expansion of rational numbers

Something like this code should work: ...
• 4,985
Accepted

### The integer ababab (a,b>0) is always divisible by 7, without remainder

One may regard this question as the test of the system ability of proving theorems, but there is another view to understand what lies beneath this theorem. Then we figure out that the problem is quite ...
• 57.7k

### Finding least n such that n^2 + 23 is divisible by large powers of 2

This is very fast: ...
• 49.3k