UPDATE NOTE
UPDATE NOTE
I should have checked it right away! High chance the sequence discussed here was already on OIES (The On-Line Encyclopedia of Integer Sequences). But what a surprise it was to see that the sequence was summited just recently on November 28, 2023 by Dr. Harvey P. Dale, who is University Professor of Philanthropy and the Law and the Director of the National Center on Philanthropy and the Law at NYU (also see here).
And Dr. Dale obtained it by much more elegant than me method, avoiding blunt search:
In[]:=
Table[Module[{k=1},While[SequenceCount[IntegerDigits[3^k],{n,n,n}]<1,k++];k],{n,0,9}]
Out[]=
{148,93,148,119,55,33,34,112,32,35}
ORIGINAL POST
ORIGINAL POST
There are more efficient methods than blind search, but for our simple task simple means are fine and they also have simple clear code. Run integers from 1 to 1000 and concatenate their digits into strings where search for triples is easy with string patterns:
In[]:=
powers=Table[{n,ToString[3^n]},{n,0,10^3}];
Use handy SelectFirst to find what we need: the first positive integer n so 3^n features a triple digit:
In[]:=
data=Table[{d,SelectFirst[powers,StringContainsQ[#[[2]],StringJoin@@ToString/@{d,d,d}]&][[1]]},{d,0,9}]
Out[]=
{{0,148},{1,93},{2,148},{3,119},{4,55},{5,33},{6,34},{7,112},{8,32},{9,35}}
To design a beautiful chart I would need a few helper functions and options. First is a labeling function that will highlight triple digits with a red frame:
In[]:=
lbl:===Row[Flatten[Split[IntegerDigits[]]/.z_List/;z[[1]]==#[[1]]&&Length[z]>1->Framed[Row@z,FrameStyleRed,RoundingRadius5,FrameMargins2,ContentPaddingFalse]]]&
Style[ToString@#[[2]],19]
3
#[[2]]
3
Second we build callouts on our data, some are Automatic and some -- a bit more manual:
callouts=MapThread[Callout[#,lbl@#,#2,CalloutMarker"CirclePoint","CalloutStyle"Red,LeaderSize30,LabelVisibility->All]&,{data,Join[{Automatic,Automatic},{{2.2,140}},Table[Automatic,7]]}];
Finally I list all the options of ListPlot I use to get the final design:
In[]:=
ListPlot[callouts,PlotStyle->Red,BaseStyle20,ImageSize1200,GridLinesAll,PlotRange{{-.5,11},{20,160}},PlotRangePadding->None,FrameTicks{Automatic,{Range[0,9],None}},FrameTrue,Background->GrayLevel[.7],PlotTheme->"GrayColor",ImageMargins->11,FrameLabel->{Style["DIGIT",23,FontFamily->"Krungthep"]},Epilog->Rotate[Text[Style["POWER",23,FontFamily->"Krungthep"],Scaled[{.015,.5}]],Pi/2]]//Rasterize
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Inception of triple digits in powers of 3 or the smallest 3^n with triple digits
by Vitaliy Kaurov
Wolfram Community, STAFF PICKS, January 6, 2024
https://community.wolfram.com/groups/-/m/t/3097624
by Vitaliy Kaurov
Wolfram Community, STAFF PICKS, January 6, 2024
https://community.wolfram.com/groups/-/m/t/3097624