0:00:00.240,0:00:05.040 Sometimes, when you're trying to come up with a  sequence or just looking into patterns and things, 0:00:05.040,0:00:10.880 you find a rule and it turns out there is no next  option. The rule you wanted just doesn't work. 0:00:10.880,0:00:16.640 Here's a sequence I found in the OEIS - the  Online Encyclopedia of Integer Sequences - that 0:00:16.640,0:00:23.680 grabbed my eye, because it's called "the  infinite trunk of least squares beanstalk". 0:00:23.680,0:00:26.640 And there's really not much  more explanation than that, 0:00:26.640,0:00:32.640 which is really... if that doesn't pique your  curiosity, what will? It says it's the only 0:00:32.640,0:00:37.280 infinite sequence - we haven't learnt anything new  yet, it said infinite at the beginning - such that 0:00:37.280,0:00:47.120 a(0) is zero and a(n-1) is a(n) minus the  least number of squares that sum to a(n). 0:00:47.840,0:00:53.120 So, it said 'least squares beanstalk'. We've  got the least number of squares again. And 0:00:53.120,0:00:59.360 then there's no other explanation about  what that means, how you work it out. Oof! 0:00:59.360,0:01:05.120 I've just spent a few minutes doodling, working  out what that means, and it's actually quite nice! 0:01:05.120,0:01:10.400 One of the problem with the OEIS is, because there  isn't much space for explaining what you mean, 0:01:10.400,0:01:17.280 the titles tend to be a bit oblique, like this  one, and then you'd want a bit more motivation, 0:01:17.280,0:01:21.600 explanation, links to things. I think the  assumption is that you will have published 0:01:21.600,0:01:25.920 something somewhere else about it.  But no such link on this entry. 0:01:25.920,0:01:40.160 So, the sequence is - and I'll copy it down -  A276573. If you're watching this when the OEIS 0:01:40.160,0:01:44.720 has moved to seven digits, hello person from  the future! I wonder how far away that is. 0:01:44.720,0:01:54.880 And it goes 0, 3, 6, 8, 11, 15, 16,  18, 21, ... and we'll stop there. 0:01:54.880,0:01:59.760 OK, so it said it's infinite. My dot-dot-dot  is correct there, it's going to go on forever. 0:01:59.760,0:02:03.680 Where do these numbers come from? What  do they mean? Where's the beanstalk? 0:02:03.680,0:02:07.280 So it says it's the only infinite  sequence such that this particular 0:02:07.280,0:02:11.440 rule is followed. So maybe there are  other ways of trying to follow this 0:02:11.440,0:02:16.960 rule that make a not infinite  sequence. So that's intriguing. 0:02:16.960,0:02:24.800 First thing to try out is - it goes 0, 3, so  start going 0, 1 must stop. So let's try that! 0:02:24.800,0:02:28.960 So I'll write my zero. We'll start  with... let's try and make it a beanstalk, 0:02:28.960,0:02:35.280 eh? So write a zero here. I'm going to  try and go upwards, like beanstalks do. 0:02:35.280,0:02:40.720 Up to 1. So does that obey the rule? What's  the rule again? I'll write it down. a(n-1) 0:02:42.000,0:02:49.200 is a(n) minus least number of squares,  which is another sequence in the OEIS, 0:02:49.200,0:02:56.960 so I'll give it its number.  A002828. Nice number! Of a(n). 0:02:58.720,0:03:06.560 Right, so I know a(n-1). That's my zero.  And I need that to... I need an a(n) that 0:03:06.560,0:03:14.320 satisfies this rule, so a next term. So does 1  satisfy it? So, if a(n) is 1, the least number 0:03:14.320,0:03:22.720 of square numbers that sum up to that is 1. 1  is a square number, 1 adds up to 1. OK, cool. 0:03:22.720,0:03:26.640 So 1 - 1 = 0. Bingo. 0:03:27.440,0:03:38.720 Now next, I need to find another number for  my a(2)... so that's a(0), that's a(1). I need 0:03:38.720,0:03:46.480 a(2) to be something that if I take away the  number of squares that add up to it, I get 1. 0:03:46.480,0:03:50.080 I don't know off the top of my head  how many squares you need to add up 0:03:50.080,0:03:56.960 to certain numbers. We could try working a  few out, I suppose. So I'll go over here... 0:03:56.960,0:04:02.680 We've got n and A002828 of n. 0:04:02.680,0:04:03.600 Bloop! 0:04:03.600,0:04:08.880 Right, so zero. How many squares add up to  zero? If I add up zero squares then I get zero. 0:04:08.880,0:04:17.600 One, one. Two, um... I need two squares.  One plus one. Three, I need three squares. 0:04:17.600,0:04:23.360 Four, that's a square number. I only need  one square number. Four's a square number. 0:04:23.360,0:04:30.320 Five is four plus one, so that's two. Six is  four plus one plus one, that's three. Seven, 0:04:32.160,0:04:34.613 four plus one plus one plus one. 0:04:34.613,0:04:36.160 For eight, four plus four, two squares! 0:04:36.160,0:04:39.040 So, right, this carries on forever. 0:04:40.720,0:04:49.600 I need a number such that the difference  between these two things is one. 0:04:49.600,0:04:53.360 Can you see one? 0:04:53.360,0:04:54.160 I can't. 0:04:54.960,0:04:58.560 Now, cleverly, I've gone off the edge  of shot there, so I'm going to go over 0:04:58.560,0:05:02.560 to the left here. So this is the difference  over here. I'll write down the differences. 0:05:02.560,0:05:08.560 0, 0, 0, 0, 3, 3, 3, 3, 6. 0:05:08.560,0:05:13.920 A person might be inclined to think at this  point, does this thing always go up? Certainly 0:05:13.920,0:05:17.600 not going to come back down to one again because  it's a theorem that every number can be written 0:05:17.600,0:05:23.840 as the sum of at most four square numbers.  OEIS says that Lagrange came up with that. 0:05:23.840,0:05:28.720 Nothing's going to have a 1 in this column,  which is what I want. So 1 doesn't work. That 0:05:28.720,0:05:35.440 is a finite beanstalk, which means  I've got to rub it out. Excuse me. 0:05:35.440,0:05:38.640 So, we're getting there. We can  rule out two by the same logic. 0:05:39.440,0:05:44.400 Can't see any twos in this column,  it's not coming back down to two. 0:05:44.400,0:05:51.360 Shall we go three? Three's the last choice I  could've had, because it's the last thing where 0:05:51.360,0:05:57.360 the difference is zero. So in order for this  to work at all, it's going to have to be three. 0:05:57.360,0:06:02.080 Sometimes, when you're trying to come up with a  sequence or just looking into patterns and things, 0:06:02.080,0:06:10.720 you find a rule and it turns out there is no next  option. The rule you wanted just doesn't work. 0:06:10.720,0:06:14.000 Right. So next term's three. 0:06:14.000,0:06:17.120 That's my a(1). So again, next, 0:06:17.120,0:06:19.840 I've got to choose the next term. What's my a(2)? 0:06:20.560,0:06:29.360 So I want something that when you take away the  number of squares counting function you get three. 0:06:29.360,0:06:33.760 So I want something with a three in this  difference column. My choices are four, five 0:06:33.760,0:06:42.960 And, yet again, I'm going to use the  fact that this differences sequence, 0:06:42.960,0:06:46.400 I don't think decreases. I'm  pretty sure it doesn't decrease. 0:06:46.400,0:06:52.000 So four is out, five is out, six will work. So just so you can -- ooh, hang on. 0:06:52.000,0:07:01.680 So a(1) is three. So a(2)...  three equals six minus, 0:07:01.680,0:07:05.040 that thing over there, the  thing in the six column. Three. 0:07:05.040,0:07:08.320 So three is six minus three. Works. Bingo. 0:07:08.320,0:07:13.520 I've got, I think, a rough idea of how this  thing works. So if I keep extending this table 0:07:13.520,0:07:21.040 down and I use the rule of, I try and look in  the column here for the last term I had, then 0:07:21.760,0:07:25.360 hopefully I'll always find something that works. 0:07:25.360,0:07:27.760 I'll quite often have a few choices. So some of 0:07:27.760,0:07:32.000 them might end up going down a dead  end that won't carry on any further. 0:07:32.000,0:07:37.360 So I'll get a trunk. And I think the beanstalk  thing is the fact that I've got this infinite 0:07:37.360,0:07:42.080 trunk that keeps going, but those other  numbers that I could have tried from there, 0:07:42.080,0:07:46.160 the other options from here, those might  be branches coming off it. Those don't 0:07:46.160,0:07:49.920 have to be infinite. I can have like  finite little branches coming off. 0:07:49.920,0:07:55.200 So, does that work? Well, off zero. I tried one, 0:07:55.200,0:08:02.800 that didn't work. And I tried two -- actually,  I'm going to do a bit of erasing again. 0:08:03.920,0:08:07.920 I'm going to start with zero much lower down  now. Zero. And I know that that goes up to 0:08:07.920,0:08:14.480 three and then six, and then looking  ahead of what I copied off the OEIS, 0:08:14.480,0:08:18.640 11, 15. Is that enough to get the idea? Let's see. 0:08:18.640,0:08:22.080 From zero, I could have tried one,  but it didn't work and I could have 0:08:22.080,0:08:27.360 tried two. That didn't work.  That's not a great two. Three. 0:08:27.920,0:08:37.520 So could four have worked from three? Let's  see. So four is the sum of one square, 0:08:37.520,0:08:46.480 so four minus one equals three. So I could have  got there from three. And the same with five. Six, 0:08:46.480,0:08:52.600 seven, ... where are we? Seven is the sum of four  squares. So that comes off three as well, whoop! 0:08:52.600,0:08:55.200 I thought that might come from further up. So 0:08:55.200,0:08:58.960 then eight's the one that works  -- sorry, six! And then eight. 0:08:58.960,0:09:06.240 Nine is, ... I need to write some  more bits. You know what? Let's go 0:09:06.240,0:09:13.040 to the OEIS. Let's find this thing. There's  a list of these. I want this table. So nine, 0:09:13.040,0:09:17.760 is the sum of one square. Well, I  could have said that, couldn't I? 0:09:17.760,0:09:23.280 Stop there. Okay. So, nine.  Oh, let's do these differences. 0:09:25.760,0:09:32.400 10 and 11 also come off eight. 12 comes  off nine. So we've got a branch that's not 0:09:32.400,0:09:38.640 trivial here. We're going two steps along,  but it will turn out to not work later on. 0:09:38.640,0:09:42.960 13, 14, 15 all come off 11. So... 0:09:42.960,0:09:49.680 The Beanstalk carries on upwards from  15. Infinitely. So there we go, that's 0:09:50.480,0:09:54.240 the infinite least squares beanstalk.  Glad I've made some sense of it. 0:09:54.240,0:09:57.200 Now there's loads of questions  that this brings up that I would 0:09:57.840,0:10:01.200 I really like to answer from  here. I'm not going to do it now. 0:10:01.200,0:10:04.720 How do we prove it's infinite? I  think if we maybe know the fact 0:10:04.720,0:10:10.640 that this thing is always monotonic,  maybe every... Well, ... here's an 0:10:10.640,0:10:15.840 easy question. Does every number fit  on to this infinite beanstalk somehow? 0:10:15.840,0:10:18.720 The answer is yes, because,  well sort of by induction. 0:10:18.720,0:10:26.480 If I've got some really big number, I then  subtract the number of squares that you need. 0:10:26.480,0:10:30.640 This function, I need to give this a better  name. The number of squares counting function. 0:10:30.640,0:10:35.360 Subtract that, I get a smaller number which,  by induction, I've said is in the Beanstalk. 0:10:35.360,0:10:41.360 So I've covered a few things here. So  I just need that to not be a gap of 0:10:41.360,0:10:48.320 four in this thing here. So, I don't know.  Maybe that is enough, maybe I've got it, 0:10:48.320,0:10:50.880 maybe I need to do a little bit more thinking. 0:10:50.880,0:10:53.440 Lovely Beanstalk. Cool!