10 {. n #~ (= |.&.":"0) (* 9+]) n=: >:i.12000
2 12 44 137 157 167 248 258 1639 1664
----- Original Message -----
From: Ian Gorse <[email protected]>
Date: Monday, August 24, 2009 23:04
Subject: [Jprogramming] Finding n where n(n+9) is an palindrome
To: [email protected]
> I have been browsing through
> http://www2.stetson.edu/~efriedma/numbers.html the past couple
> of days, I
> have been using it to try my own personal problem solving to educate
> myself with J
>
> For example:
> 258 is a value of n so that n(n+9) is a palindrome.
>
> I set out to find the first 10 numbers that meet this criteria
> and I
> came up with this..
>
> 10 {. n #~ ,( ( ] = [: ". [: |. ": ) ] * +&9 ) "0 ( n =. >:
> i.12000 )
> 2 12 44 137 157 167 248 258 1639 1664
>
> As you can see, I have already found my answers but this is just an
> educational request.
> I am just looking for some alternative solutions so I can read and
> digest the different ways it can be done. Ideally with the use
> of the
> @ conjuction as
> I have recently been understanding the conjuction @ a lot more,
> as I
> find the 'flow' of reading the J expression more fluent.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm