I beg to differ
1000001 gets 666669166671000001
10000001 gets 666666916666710000001

Try  n #. 4 3 8 _9%6x   for desired odd n

Ralph Selfridge


On Tue, 4 Dec 2007, JC Coez wrote:


Probably ugly but it seems to work...

     z=:x:@(1+@:+/@:,4*1+]+4*]^2:)}.&i.&>.&-:
 z 1001
669171001
 z 10001
666916710001
 z 100001
666691667100001
 z 1000001
666669166671981696
 z 10000001
666666916666722877440
 z 100000001
|out of memory: z
|       z 100000001

JCC
----- Original Message ----- From: "Roger Hui" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Monday, December 03, 2007 1:38 AM
Subject: Re: [Jprogramming] New to J


FYI: Problem 28 in www.ProjectEuler.net is as follows:

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:

21 22 23 24 25
20  7  8  9 10
19  6  1  2 11
18  5  4  3 12
17 16 15 14 13

It can be verified that the sum of both diagonals is 101.

What is the sum of both diagonals in a 1001 by 1001 spiral formed in the same way?



----- Original Message -----
From: Joey <[EMAIL PROTECTED]>
Date: Sunday, December 2, 2007 15:43
Subject: Re: [Jprogramming] New to J
To: Programming forum <[email protected]>

Yes, I found [ -(i.4) * ], soo after your post.

I am using that particular code here:
    f =: 3 : 'x:+/y -(i.4)*] (%:y)+_1'
    1++/f"0 *:>:2*>:i.500
Which is #28 on Project Euler, which I am using to learn J!

I tried f =: 13 : 'x:+/y -(i.4)*] (%:y)+_1', then f; but the
result was
boxed, and I wasn't sure how it should be formatted.
So how can I replace the definiton of f, into 1++/f"0 *:>:2*>:i.500.
And are there any things I am doing wrong in my code?
----------------------------------------------------------------------
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

Reply via email to