<p>I am given a number with 1000 digits and was wondering if there's a simple way to store the individual digits.</p>
<p>I tried the obvious thing of letting x = (large number) and the program broke down because the number was clearly too large. </p>
<hr/>**评论:**<br/><br/>pdq: <pre><p><a href="https://golang.org/pkg/math/big/" rel="nofollow">https://golang.org/pkg/math/big/</a></p></pre>barsonme: <pre><p>What are you intending to do with this number?</p></pre>DJysyed: <pre><p>I want to look at all the products of 13 consecutive digits of the number and determine the largest of them</p></pre>barsonme: <pre><p>I'd just keep it as a string, then. or []byte.</p></pre>jerf: <pre><p>Yes. A digit's value is that byte - 48, which you can see from an <a href="http://www.asciitable.com/" rel="nofollow">ASCII table</a>. The best thing to do would be to clean it up front and do one pass to convert the digits into their numerical values, then un-convert them on the way back out to print the answer.</p>
<p>There's no point un-base-10'ing the number with a bignum library just to have to sit there and manually re-base-10 the number to process it by digits when the initial input already had it broken out by base 10 digits, just with 48 added to each digit....</p></pre>sajattack: <pre><p><a href="https://github.com/sajattack/go-euler/blob/master/08/main.go" rel="nofollow">https://github.com/sajattack/go-euler/blob/master/08/main.go</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传