22

We can take advantage of the fact that IntegerDigits is very fast when the base is large. But not too large: no bigger than $2^{63}-1$ on a 64-bit system or $2^{31}-1$ on a 32-bit one, because Mathematica's machine integers are signed. Additionally, non-power-of-two bases require more work to get the result than just partitioning a bit-string, and are ...


22

We can exploit the built in LogGamma: x = 12345678987654321; Ceiling[LogGamma[N[x + 1]]/Log[10]] 193299018111544064 Edit, Addressing precision: We have naively for $n > 1$, that $n! < n^n$. Taking logs of both sides gives the (not very tight) bound $\log\Gamma(x + 1) < x \log(x)$ for $x > 1$. This means if we want the number of digits of $n!$...


17

There are any number of discrete statistical distributions defined on the natural set of numbers (positive integers): $$\{1,2,3, ..., \infty\}$$ Geometric Perhaps the best known such distribution is the Geometric with pmf: $$P(X=x) = p (1-p)^{x-1} \quad \text{for} \quad x = 1, 2, ...$$ with parameter $0<p<1$. Mathematica's implementation of the ...


16

Mathematica 10 introduces IntegerName: IntegerName[n] gives a string containing the full English name of the integer n. IntegerName[n,"type"] gives a string of the specified type. Possible types include: "DigitsWords" a combination of three-digit numbers and words "Words" using only words "Approximate" the first few digits ...


14

I think you underestimate how many digits this number has. Even if you used scientific notation, the exponent would overflow your PC's memory, so you'd need scientific notation for the scientific notation. I'm not sure which number format you expect to get, but I think the form it's already in is probably the most useful. But let's try to get an idea for ...


14

FromDigits@Flatten[IntegerDigits /@ Range[15]] 123456789101112131415 A function to do it: numberFromRange[n_] := FromDigits@Flatten[IntegerDigits /@ Range@n]


13

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 result. (It turns out that the machine precision answer is correct.) LogGamma can be expanded around infinity thusly: Series[LogGamma[z], {z, Infinity, 4}] to ...


11

f1 = OrderedQ @* Rest @* IntegerDigits; f1 /@ {51369, 51396} {True, False} f2 = Apply[LessEqual @ ##2 &] @* IntegerDigits; f2 /@ {51369, 51396} {True, False}


10

f1 = FromDigits @ StringRiffle[Range[#], ""] &; f1 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} And f2 = FromDigits @* StringJoin @* IntegerString @* Range; f2 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} A variation on @user1066's answer: f3 = Array[IntegerString, #, 1, FromDigits @* StringJoin] &; f3 /@ {5,...


9

However, the only method I've found that ensures numerically exact conversion is the manual one: delete the decimal point, and then divide by 10^z, where z is the number of digits to the right of the decimal. This does not produce an exact conversion because floating point numbers are represented in binary, not in decimal. I tried SetPrecision[a,Infinity]...


9

One way would be to split the large number in smaller chunks, convert each of them to a string, which can be manipulated, and then exporting. bigNumber = 10000!; output = (StringJoin @@ #) & /@ Partition[ToString[#] & /@ IntegerDigits[bigNumber], 40, 40, {1, -1}] ; (* each line has 40 digits *) (* Make font smaller and red for all lines ...


8

Never use pattern matching unless you absolutely have to. Using Cases instead of Select can make a huge difference. Vectorize operations. Use Range instead of Table if you can. Test several things at once. And[test1, test2, test3] will abort when it can for maximum efficiency ("short circuit evaluation"). Taking this into consideration your code looks like ...


8

Since we are dealing with very large numbers, so one of the option is to use ListLogPlot P[x_]:= Your large expression here ListLogPlot[Table[{x, P[x]}, {x, 0, 100, 10}], PlotRange -> All, Frame -> True] For roots try with NSolve or FindRoot NSolve[P[x] == 0, x]


8

You can use BitLength or IntegerLength: BitLength[number] 4091 IntegerLength[number, 2] 4091


8

Without using IntegerDigits or string processing: f[x_] := Last@NestWhile[#[[1]]+{1,#[[2]]*10^IntegerLength@#[[1]]}&,{1,0},#[[1]]<=x&] f[105] (* 1234567891011121314151617181920212223242526272829303132333435363738394 0414243444546474849505152535455565758596061626364656667686970717273747 ...


7

Hmm, I just posted an answer yesterday that overcame just this problem with the undocumented option "SolveDiscreteSolutionBound" that controls a system limit: With[{ropts = SystemOptions["ReduceOptions"]}, Internal`WithLocalSettings[ SetSystemOptions[ "ReduceOptions" -> "SolveDiscreteSolutionBound" -> (1400*10^9)], Solve[y^2 == 441 + 48*x*(...


6

You should take advantage of the fact that a^b == c^(Log[c,a] b) so that E^(E^(10^72)) == 10^(Log[10,E] E^(10^72)) == 10^(Log[10,E] 10^(Log[10,E] 10^72)) Since Log[10,E] (that is, ln(10)) is about 2.3, the number of digits in your quantity (in base 10) is ~ 2.3 10^(2.3*10^72)


6

Here's one way, using Carl Woll's suggestion of MemoryConstrained, which runs very quickly: Do[ ans[t] = MemoryConstrained[ ReplacePart[pattern, Thread[Position[pattern, o] -> t]], 8*^9, (* depending on how much memory you have *) $Failed[t]], {t, tps} ] General::ovfl: Overflow occurred in computation. You can do this with Map ...


6

I offer the following as a fast way of testing cubic and higher powers primes = Select[Range[59], PrimeQ] Get a list of all the relevant powers up to a specified limit list[nmax_] := Sort[Flatten[Table[Range[2, Floor[nmax^(1/p)]]^p, {p, Drop[primes, 1]}]]]; For example list[1000] (* {8, 27, 32, 64, 125, 128, 216, 243, 343, 512, 729, 1000} *) Define an ...


5

There is this way: SetAttributes[test, Listable] test[n_] := FirstPosition[Reverse[#[[2 ;; Ceiling[Length[#]/2]]] &[ Divisors[n]]], _?(IntegerQ[Log[#, n]] &), 0] =!= 0 Pick[#, test[#]] &[Range[1000]]


5

I want to show that without hypotheses, the problem of determining whether $x=a/\pi$ came from a rational number is unsolvable. But, spoiler alert, the OP's number 2.47... is probably not a rational multiple of Pi or it is not precise enough to determine whether it is. First, a floating-point number $x$ comes with an uncertainty $dx$. If $x$ comes from ...


5

ToExpression[ StringJoin[ ToString /@ Range[15] ] ]


5

Timings for all the methods (g1 : murray, g2 : flinty, g3/g4 : AccidentalFourierTransform, g5/g6 : Syed, g7 : David Reiss, g8 : user1066, g9/g10/g11 : kglr) posted so far: ClearAll[g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, funcs] g1 = FromDigits @ Flatten[IntegerDigits /@ Range[#]] &; g2[x_] := Last @ NestWhile[#[[1]] + {1, #[[2]]*10^IntegerLength@#...


5

f = AllTrue[Rest[Differences[IntegerDigits[#]]], Positive] & Test: f /@ {51369, 412345, 824699, 41395, 31832} True, True, False, False, False} EDIT Visually, alist = Range[1000]; blist = (Boole /@ f /@ alist) /. {{} -> Black, 0 -> Red, 1 -> Darker@Green} // Multicolumn


4

Your first port of call should be to have a look at the documentation for $MaxNumber, which says: $MaxNumber gives the maximum arbitrary‐precision number that can be represented on a particular computer system. On my machine, $MaxNumber returns $1.605216761933662 \times 10^{1355718576299609}$. With regards to your number, $44^{6553700000000}$, I ...


4

How many (not-necessarily-prime) factors of $200!$ are there? First, get all the prime factors. (The maximum such factor will be less than $200$, of course--in fact it is $199$.) FactorInteger[200!] gives each prime factor with its multiplicity: {{2, 197}, {3, 97}, {5, 49}, {7, 32}, {11, 19}, {13, 16}, {17, 11}, {19, 10}, {23, 8}, {29, 6}, {31, 6}, {37, ...


4

Might I suggest not making a plot like that? Whatever information that you are trying to get across will likely be clearer if you plot with x-values relative to $10^{15}$ and note that in the axes label or the caption: ListPlot[Transpose[Transpose[myList] - {10^15, 0}], PlotRange -> {{0, 3}, {0, 2}}] If you really want big numbers on the axis, you could ...


4

Here's a direct search using a fast square test from this answer: sQ[n_] := FractionalPart@Sqrt[n + 0``1] == 0 Reap[Do[If[sQ[441 + 48*x*(1 + x) (-13 + 16*x)], Sow[x]], {x, 2*10^7}]][[2,1]] //AbsoluteTiming (* {91.0767, {1}} *) So in 91 seconds we've checked up to $x\le2\times10^7$, which corresponds to $y\le2478\times10^9$. Using parallel ...


4

You want $10^{13}\leq y\leq 10^{14}$, so obviously $10^{26}\leq y^2\leq 10^{28}$. The range of $x$ for which your expression $10^{26}\leq y^2 = 2213326116 + 94098\ x\ (1 + x) (-31363 + 31366\ x)\leq 10^{28}$ can be easily found: N@Reduce[10^26 < 2213326116 + 94098 x (1 + x) (-31363 + 31366 x) <= 10^28, x] 323584. < x <= 1.50194*10^6 That's ...


4

This uses less memory: Last@Reap@Do[ With[{n = Sqrt[1 + 12 x^2 (1 + x) + 0``1]}, (* <-- N.B. *) If[FractionalPart@n == 0, Sow@{x, Round[n]}]] &, {x, 10^(10)}] On my machine the first and last 10^6 iterations take about 0.4 seconds, so I project it might finish in less than an hour and a half.


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