25 votes
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 ...
yarchik's user avatar
  • 18k
24 votes
Accepted

Visualisation of the field of algebraic numbers in the complex plane

Your code works fine, but it's missing half the roots, and a Flattening of the list of numbers prior to applying Re and ...
DumpsterDoofus's user avatar
24 votes
Accepted

InverseTotient[ ]?

Perhaps: Reduce`EulerPhiInverse[6] (* {7, 9, 14, 18} *) Not sure why such things are hidden & undocumented, perhaps because it's available through ...
Michael E2's user avatar
  • 234k
22 votes

Number of digits for factorial of 12345678987654321

We can exploit the built in LogGamma: x = 12345678987654321; Ceiling[LogGamma[N[x + 1]]/Log[10]] ...
Greg Hurst's user avatar
  • 35.8k
21 votes
Accepted

Double Sum Involving Condition

A story of incremental improvement Let's look at the OP's original expression again, for reference: $$\sum_{m=1}^{c}\frac{1}{m}\sum_{d \mid m}\mu(d)n^{m/d}$$ Most people here are familiar with <...
J. M.'s eventual burnout's user avatar
20 votes

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: ...
ciao's user avatar
  • 25.7k
19 votes
Accepted

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

A Trace reveals the problem: ...
Michael E2's user avatar
  • 234k
18 votes
Accepted

SquaresR memory leak?

Cause Under the hood System`SquaresR is still calling functions in the context NumberTheory`. Partial output of: ...
Mr.Wizard's user avatar
  • 271k
18 votes

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 ...
yarchik's user avatar
  • 18k
17 votes

Determining if a number is divisible by 1000

Use Divisible: Divisible[a, 1000] False
kglr's user avatar
  • 392k
16 votes

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 ...
KennyColnago's user avatar
  • 15.2k
15 votes

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

If you need all the primes that are twin primes up to n then. ...
rhermans's user avatar
  • 36.3k
15 votes

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: ...
C. E.'s user avatar
  • 70.4k
15 votes

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 ...
Michael Seifert's user avatar
14 votes
Accepted

Fastest square number test

Here's an idea similar to Carl Woll's that's a little faster: ...
Michael E2's user avatar
  • 234k
14 votes

Accuracy of PrimeQ function

Turning my comment into an answer, One of the tests performed by PrimeQ for machine-sized integers, namely Miller-Rabin using up to the first 12 primes as bases (...
ilian's user avatar
  • 25.5k
14 votes

Finding vampire numbers

Consider the trusty DivisorPair function from MrWizard: ...
KennyColnago's user avatar
  • 15.2k
14 votes
Accepted

Making the number 12345...n

FromDigits@Flatten[IntegerDigits /@ Range[15]] 123456789101112131415 A function to do it: ...
murray's user avatar
  • 11.8k
13 votes
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....
Arnoud Buzing's user avatar
13 votes

Number of digits for factorial of 12345678987654321

I wondered if Chip's answer was exactly correct, given Daniel's comment about machine precision. So I did it a little differently with higher precision in a way that gives good confidence in the ...
Mark Adler's user avatar
  • 4,949
13 votes
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 ...
yarchik's user avatar
  • 18k
13 votes
Accepted

Plotting the sum of two points on an elliptic curve

Here's a starting point: ...
J. M.'s eventual burnout's user avatar
13 votes

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 ...
halirutan's user avatar
  • 113k
13 votes
Accepted

Zeckendorf representation

Here's a greedy algorithm, using results from here: ...
J. M.'s eventual burnout's user avatar
13 votes
Accepted

Drawing a sequence of circles

Graphics[ {r = Length[Divisors@#]/2; ColorData["Rainbow"][(r - 1)/7], Circle[{#, 0}, r]} & /@ Range[150], ImageSize -> 504]
Bob Hanlon's user avatar
  • 155k
12 votes
Accepted

Goldbach Partition

Take a look at IntegerPartitions, although it relies on brute-force enumeration that is unlikely to scale well. ...
Mr.Wizard's user avatar
  • 271k
12 votes

Find the number of $n$ such that $n!$ is a sum of three squares

Brute-force, but compact: DeleteCases[Table[{k, PowersRepresentations[k!, 3, 2]}, {k, 10}], {___, 0, ___}, {3}] ...
J. M.'s eventual burnout's user avatar
12 votes
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,...
Syed's user avatar
  • 48.6k
11 votes

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 ...
Julien Kluge's user avatar
  • 5,335
11 votes

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 ...
KennyColnago's user avatar
  • 15.2k

Only top scored, non community-wiki answers of a minimum length are eligible