Skip to main content
26 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
  • 19.3k
25 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
  • 241k
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.9k
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
  • 241k
19 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
  • 19.3k
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
  • 273k
17 votes

Determining if a number is divisible by 1000

Use Divisible: Divisible[a, 1000] False
kglr's user avatar
  • 399k
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.3k
16 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
  • 37k
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
  • 71k
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
  • 241k
14 votes

Finding vampire numbers

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

Making the number 12345...n

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

Plotting the sum of two points on an elliptic curve

Here's a starting point: ...
J. M.'s missing motivation'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 missing motivation'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
  • 161k
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
  • 56.2k
12 votes
Accepted

Checking if a number is right sorted

f1 = OrderedQ @* Rest @* IntegerDigits; f1 /@ {51369, 51396} {True, False} ...
kglr's user avatar
  • 399k
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,470
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.3k
11 votes
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: ...
Michael E2's user avatar
  • 241k
11 votes
Accepted

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

Something like this code should work: ...
Somos's user avatar
  • 4,985
11 votes
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 ...
Artes's user avatar
  • 57.7k
11 votes

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

This is very fast: ...
Roman's user avatar
  • 49.3k
11 votes

All solutions that satisfy $ x_{1}^{5}+x_{2}^{5}+x_{3}^{5}+x_{4}^{5}-x_{5}^{5}=0 $

I am a bit surprised that not a Mathematica solution with a statement "I don't think Mathematica is suited for this kind of problem." is accepted. I do believe that Mathematica is well ...
yarchik's user avatar
  • 19.3k
10 votes

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

An alternative formulation of RealDigits that I prefer: RealDigits[7/101, 10, 1, -5566][[1, 1]] (* 6 *) This yields better ...
Mr.Wizard's user avatar
  • 273k

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