Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.2K Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ListLinePlot of the length of the sequence of digits

Posted 1 year ago

I'm going through the language introduction course and I'm stuck on question 6.13. It asks, "Make a list line plot of the length of the sequence of digits for each of the first 100 squares."

I started by doing a Table to make sure I was getting the right data:

Table[Length[IntegerDigits[k^2]], {k, 100}]

But when I swap Table for ListLinePlot...that's where I'm having issues and the documentation is so obtuse. I changed it to what's below but it errors out and I can't seem to figure out the error (I added the spaces to make it more readable here).

ListLinePlot [ { [Length[IntegerDigits[k^2] ], {k, 100} ], 100} ]  

Thanks in advance!

POSTED BY: Steve Ruzila
7 Replies
Posted 1 year ago

Don't swap, use them in tandem. The plot following after the table. Like this:

Table[Length[IntegerDigits[k^2]], {k, 100}] // ListLinePlot

or like this:

ListLinePlot@Table[Length[IntegerDigits[k^2]], {k, 100}]
POSTED BY: Hans Milton
Posted 1 year ago

Ah, I didn't realize i needed to have the Table function in there too! That was it! Thank you very much!

POSTED BY: Steve Ruzila
Posted 1 year ago

A few comments:

  • Check out IntegerLength. That'll clean things up a bit.
  • I don't understand why you're trying to "swap Table for ListLinePlot". ListLinePlot needs a list of data, and Table produces a list of data, so you don't want to swap, but you want to wrap.
  • This code ListLinePlot [ { [Length[IntegerDigits[k^2] ], {k, 100} ], 100} ] has a pretty obvious syntax error. I'm not sure if maybe that's just an error in putting together your question or if the errors are in your actual code. Specifically, you're using [ where there is no head preceding it, and that's just a basic syntax error.

Is that enough help, or are you asking for actual working code that solves the problem?

Side note, is this tutorial online, and if so, can you provide a link to this question?

POSTED BY: Eric Rimbey
Posted 1 year ago

Eric, the question is from here. Exercise 6.8

POSTED BY: Hans Milton
Posted 1 year ago

I originally assumed it came from that tutorial, but the OP said is was question 6.13, and I don't see any 6.13. Also, 6.8 makes it sound like we're supposed to sum the digits. I'm confused.

POSTED BY: Eric Rimbey
Posted 1 year ago
Posted 1 year ago

Thanks!

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard