The neatest I can come up with is

   f=: (2 * j) %~ j - ~]

   i.&.((>....@f m)-~])@ >.&.f n
55 65 75 85 95 105 115
   
Notice that f maps [m,n) to an interval in which you determine the integers,
on which you apply f^:_1
Of course this is essentially Zsbán Ambrus solution.


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens R.E. Boss
> Verzonden: vrijdag 4 juni 2010 19:06
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] odd multiples
> 
> Knowing Hui likes &. I suggest
> 
>    (4 :'i.&.(-&x)y')/@:>.&.:(-:@:<:@:(%&j)) m,n
> 55 65 75 85 95 105 115
> 
> 
> R.E Boss
> 
> 
> > -----Oorspronkelijk bericht-----
> > Van: [email protected] [mailto:programming-
> > [email protected]] Namens Zsbán Ambrus
> > Verzonden: vrijdag 4 juni 2010 14:03
> > Aan: Programming forum
> > Onderwerp: Re: [Jprogramming] odd multiples
> >
> > On Fri, Jun 4, 2010 at 7:31 AM, Roger Hui <[email protected]> wrote:
> > > j, m, and n are positive integers with m<n.
> > > Find a neat expression for all the odd multiples of j in [m,n),
> > > that is, all k such that (m<:k)*.(k<n)*.(1=2|k%j) .
> >
> >    'j m n'=: 5 50 120
> >    range=: [+i.@:(0&>.)@:-~
> >    range/@:>.&.:(-:@:<:@:(%&j)) m,n
> > 55 65 75 85 95 105 115
> >
> > As you require m<n, you could omit the ((0&>.)@:) part.
> >
> > Ambrus
> > ----------------------------------------------------------------------
> > 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