Merge numbers to a new number and find digit on position (n)Brackets in output make unable to use output to identify matrix elementWhat does the slash-colon symbol do?Splicing a list of arguments into a function with SequenceBincounting a listimport a list of replacement rulesFinding a number which has the same remainder when dividing certain other numbersNegative accuracy numerics ( 0``-128 notation )Please explain the following code containing Partition and FlattenDifference between f[x] and f as arguments of functionsEvaluating an expression on one line
Feasible explanation to the continued existence of dangerous magical creatures in a modern setting
Convex subsets of an open set
What's objectionable about the Axiom of Countable Additivity?
Extracting solutions from ContourPlot
Name for geostationary orbit around another planet
What difference does horsepower make? If the engine can spin the propeller fast enough, why does it need power behind it?
Is a job offer letter with no mention of salary structure legal or correct?
Drawing between two nodes in Tikz
Is there any other sparse matrix data in matlab built-in file?
Rite of Winter: How to Stop Crescian Couples from Mutual Assassination
What can I do at Hong Kong Airport for 13 hours?
Can I freely use 'here is' instead of 'there is' if I'm in the place where that thing is?
Is it normal to not be able to work 8 hours a day?
Can airpod with wrong spelling on the case be original?
Why does the monotone convergence theorem not apply on Riemann integrals?
Can I travel to UK as a cabin crew after being refused entry to Ireland?
Reduction of amino acids to corresponding amino alcohols
LilyPond - change tuplet bracket to a small bow
Do fresh chilli peppers have properties that ground chilli peppers do not?
Aliens kill as an art form, surprised that humans don't appreciate
Is my visualization of a photon correct?
Can I apply for a passport in the country I'm in so I can travel to my home country?
Do the holes in Jacquard loom punched cards represent input data or program code?
How can baseline humanity survive on its own in the future?
Merge numbers to a new number and find digit on position (n)
Brackets in output make unable to use output to identify matrix elementWhat does the slash-colon symbol do?Splicing a list of arguments into a function with SequenceBincounting a listimport a list of replacement rulesFinding a number which has the same remainder when dividing certain other numbersNegative accuracy numerics ( 0``-128 notation )Please explain the following code containing Partition and FlattenDifference between f[x] and f as arguments of functionsEvaluating an expression on one line
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;
$begingroup$
I'm trying to construct a 'Mathematica solution' for the following 'puzzle'
The natural numbers are placed in a row;
12345678910111213...
What digit is the 10,000th digit?
I don't know the syntax how to form this number, or to extract digit $n$ (in the example $n=10000$) in Mathematica. Anybody that can help? TIA.
syntax
$endgroup$
add a comment
|
$begingroup$
I'm trying to construct a 'Mathematica solution' for the following 'puzzle'
The natural numbers are placed in a row;
12345678910111213...
What digit is the 10,000th digit?
I don't know the syntax how to form this number, or to extract digit $n$ (in the example $n=10000$) in Mathematica. Anybody that can help? TIA.
syntax
$endgroup$
$begingroup$
Take a look at the documentation ofIntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure
$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47
add a comment
|
$begingroup$
I'm trying to construct a 'Mathematica solution' for the following 'puzzle'
The natural numbers are placed in a row;
12345678910111213...
What digit is the 10,000th digit?
I don't know the syntax how to form this number, or to extract digit $n$ (in the example $n=10000$) in Mathematica. Anybody that can help? TIA.
syntax
$endgroup$
I'm trying to construct a 'Mathematica solution' for the following 'puzzle'
The natural numbers are placed in a row;
12345678910111213...
What digit is the 10,000th digit?
I don't know the syntax how to form this number, or to extract digit $n$ (in the example $n=10000$) in Mathematica. Anybody that can help? TIA.
syntax
syntax
asked Oct 16 at 18:14
mf67mf67
6091 silver badge6 bronze badges
6091 silver badge6 bronze badges
$begingroup$
Take a look at the documentation ofIntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure
$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47
add a comment
|
$begingroup$
Take a look at the documentation ofIntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure
$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47
$begingroup$
Take a look at the documentation of
IntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Take a look at the documentation of
IntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47
add a comment
|
2 Answers
2
active
oldest
votes
$begingroup$
The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits.
In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]
. To get the 10,000 digit, just use RealDigits
:
RealDigits[ChampernowneNumber[], 10, 1, -10000][[1, 1]]
7
$endgroup$
add a comment
|
$begingroup$
A (much slower) procedural method.
First we find the number of digits of 123...(n-1)n
.
numlength[n_] := With[
pow = Floor@N@Log10[n],
Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1)
]
Here pow = Floor@N@Log10[n]
gives the order of magnitude (OoM) of n
, Range[pow]
and (pow + 1)
gives the number of digits in each OoM and the last OoM, respectively, 9*10^Range[0, pow - 1]
and (n - 10^pow + 1)
gives the number of numbers in each OoM and the last OoM. So the final output is the number of digits in the number 123...(n-1)n
.
Then, because I couldn't think of a better way,
proc[limit_] := Block[
n = 1,
While[numlength[n] <= limit, n++];
If[numlength[n - 1] == limit, Mod[n - 1, 10], IntegerDigits[n][[limit - numlength[n - 1]]]]
]
While it's much slower than @CarlWoll's method, and definitely not the best method, it still works.
proc[10^4] // RepeatedTiming
RealDigits[ChampernowneNumber[], 10, 1, -10^4][[1, 1]] // RepeatedTiming
0.032, 7
0.000086, 7
$endgroup$
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f208013%2fmerge-numbers-to-a-new-number-and-find-digit-on-position-n%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits.
In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]
. To get the 10,000 digit, just use RealDigits
:
RealDigits[ChampernowneNumber[], 10, 1, -10000][[1, 1]]
7
$endgroup$
add a comment
|
$begingroup$
The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits.
In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]
. To get the 10,000 digit, just use RealDigits
:
RealDigits[ChampernowneNumber[], 10, 1, -10000][[1, 1]]
7
$endgroup$
add a comment
|
$begingroup$
The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits.
In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]
. To get the 10,000 digit, just use RealDigits
:
RealDigits[ChampernowneNumber[], 10, 1, -10000][[1, 1]]
7
$endgroup$
The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits.
In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]
. To get the 10,000 digit, just use RealDigits
:
RealDigits[ChampernowneNumber[], 10, 1, -10000][[1, 1]]
7
answered Oct 16 at 19:03
Carl WollCarl Woll
98.4k4 gold badges133 silver badges247 bronze badges
98.4k4 gold badges133 silver badges247 bronze badges
add a comment
|
add a comment
|
$begingroup$
A (much slower) procedural method.
First we find the number of digits of 123...(n-1)n
.
numlength[n_] := With[
pow = Floor@N@Log10[n],
Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1)
]
Here pow = Floor@N@Log10[n]
gives the order of magnitude (OoM) of n
, Range[pow]
and (pow + 1)
gives the number of digits in each OoM and the last OoM, respectively, 9*10^Range[0, pow - 1]
and (n - 10^pow + 1)
gives the number of numbers in each OoM and the last OoM. So the final output is the number of digits in the number 123...(n-1)n
.
Then, because I couldn't think of a better way,
proc[limit_] := Block[
n = 1,
While[numlength[n] <= limit, n++];
If[numlength[n - 1] == limit, Mod[n - 1, 10], IntegerDigits[n][[limit - numlength[n - 1]]]]
]
While it's much slower than @CarlWoll's method, and definitely not the best method, it still works.
proc[10^4] // RepeatedTiming
RealDigits[ChampernowneNumber[], 10, 1, -10^4][[1, 1]] // RepeatedTiming
0.032, 7
0.000086, 7
$endgroup$
add a comment
|
$begingroup$
A (much slower) procedural method.
First we find the number of digits of 123...(n-1)n
.
numlength[n_] := With[
pow = Floor@N@Log10[n],
Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1)
]
Here pow = Floor@N@Log10[n]
gives the order of magnitude (OoM) of n
, Range[pow]
and (pow + 1)
gives the number of digits in each OoM and the last OoM, respectively, 9*10^Range[0, pow - 1]
and (n - 10^pow + 1)
gives the number of numbers in each OoM and the last OoM. So the final output is the number of digits in the number 123...(n-1)n
.
Then, because I couldn't think of a better way,
proc[limit_] := Block[
n = 1,
While[numlength[n] <= limit, n++];
If[numlength[n - 1] == limit, Mod[n - 1, 10], IntegerDigits[n][[limit - numlength[n - 1]]]]
]
While it's much slower than @CarlWoll's method, and definitely not the best method, it still works.
proc[10^4] // RepeatedTiming
RealDigits[ChampernowneNumber[], 10, 1, -10^4][[1, 1]] // RepeatedTiming
0.032, 7
0.000086, 7
$endgroup$
add a comment
|
$begingroup$
A (much slower) procedural method.
First we find the number of digits of 123...(n-1)n
.
numlength[n_] := With[
pow = Floor@N@Log10[n],
Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1)
]
Here pow = Floor@N@Log10[n]
gives the order of magnitude (OoM) of n
, Range[pow]
and (pow + 1)
gives the number of digits in each OoM and the last OoM, respectively, 9*10^Range[0, pow - 1]
and (n - 10^pow + 1)
gives the number of numbers in each OoM and the last OoM. So the final output is the number of digits in the number 123...(n-1)n
.
Then, because I couldn't think of a better way,
proc[limit_] := Block[
n = 1,
While[numlength[n] <= limit, n++];
If[numlength[n - 1] == limit, Mod[n - 1, 10], IntegerDigits[n][[limit - numlength[n - 1]]]]
]
While it's much slower than @CarlWoll's method, and definitely not the best method, it still works.
proc[10^4] // RepeatedTiming
RealDigits[ChampernowneNumber[], 10, 1, -10^4][[1, 1]] // RepeatedTiming
0.032, 7
0.000086, 7
$endgroup$
A (much slower) procedural method.
First we find the number of digits of 123...(n-1)n
.
numlength[n_] := With[
pow = Floor@N@Log10[n],
Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1)
]
Here pow = Floor@N@Log10[n]
gives the order of magnitude (OoM) of n
, Range[pow]
and (pow + 1)
gives the number of digits in each OoM and the last OoM, respectively, 9*10^Range[0, pow - 1]
and (n - 10^pow + 1)
gives the number of numbers in each OoM and the last OoM. So the final output is the number of digits in the number 123...(n-1)n
.
Then, because I couldn't think of a better way,
proc[limit_] := Block[
n = 1,
While[numlength[n] <= limit, n++];
If[numlength[n - 1] == limit, Mod[n - 1, 10], IntegerDigits[n][[limit - numlength[n - 1]]]]
]
While it's much slower than @CarlWoll's method, and definitely not the best method, it still works.
proc[10^4] // RepeatedTiming
RealDigits[ChampernowneNumber[], 10, 1, -10^4][[1, 1]] // RepeatedTiming
0.032, 7
0.000086, 7
answered Oct 17 at 2:02
That Gravity GuyThat Gravity Guy
4,1161 gold badge7 silver badges21 bronze badges
4,1161 gold badge7 silver badges21 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f208013%2fmerge-numbers-to-a-new-number-and-find-digit-on-position-n%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Take a look at the documentation of
IntegerDigits
, that should solve your problem. To get enough digits, you can either try to work out exactly how many numbers you need to concatenate, or you could also just take enough (i.e. 10000) to make sure$endgroup$
– Lukas Lang
Oct 16 at 18:16
$begingroup$
Flatten[IntegerDigits /@ Range[5000]][[10000]]
$endgroup$
– OkkesDulgerci
Oct 16 at 19:47