Are you looking for something like this for "figure 2.1"?
o=: _1 1 }. ":@<@(,~ 'o ' $~ {:@$)@(,. ' o' $~ #)
o o o o _1 1 }.":<'o'
─────────┐
o o o o o│
───────┐ │
o o o o│o│
─────┐ │ │
o o o│o│o│
───┐ │ │ │
o o│o│o│o│
─┐ │ │ │ │
o│o│o│o│o│
Thanks,
--
Raul
On Tue, May 15, 2018 at 9:42 AM, Jimmy Gauvin <[email protected]> wrote:
> Hi all,
>
> In "Makers of Mathematics" by Stuart Hollingdale there is a reference about
> Pythagoreans who where in the habit of representing numbers by pebbles in
> the sand.
>
> Figure 2.1 illustrates how square numbers can be generated by adding
> successive odd numbers.
>
> ───────┐
> o o o o│
> ─────┐ │
> o o o│o│
> ───┐ │ │
> o o│o│o│
> ─┐ │ │ │
> o│o│o│o│
>
>
> The sum of first n odd numbers is simply n^2.
>
> How about some J code to generate figure 2.1 ?
>
>
>
>
>
> On Tue, May 15, 2018 at 5:22 AM, 'Jon Hough' via Programming <
> [email protected]> wrote:
>
>> Try this:
>>
>> smodd1=:+/@:>:@:+:@:i.
>>
>> Your tacit verb was creating forks, as can be seen with dissect:
>> load 'debug/dissect'
>> dissect '+/1+2*i. 5'
>>
>>
>> But since the sum of the first N odd numbers is N^2
>> it is easiest to write
>> smodd=: *:
>>
>>
>> --------------------------------------------
>> On Tue, 5/15/18, Skip Cave <[email protected]> wrote:
>>
>> Subject: [Jprogramming] Summing odd numbers
>> To: "[email protected]" <[email protected]>
>> Date: Tuesday, May 15, 2018, 5:29 PM
>>
>> A simple Quora question wants to know the
>> formula to sum the first n odd
>> numbers.
>>
>> I can write an explicit verb:
>>
>> smodd =.3 :'+/1+2*i.y'
>>
>> smodd 5
>>
>> 25
>>
>> I want to write a tacit verb:
>>
>> smodd1=:+/1+2*i.
>>
>> smodd1 5
>>
>> 6 8 10 12 14
>>
>> What am I doing wrong?
>>
>>
>> Skip Cave
>> Cave Consulting LLC
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm