[Jprogramming] Exponentiation with subtraction
Roger Hui
RHui000 at shaw.ca
Thu Jan 26 14:38:35 HKT 2006
To get rid of the constants from my solution,
replace the first 0 by -~@[ and the others by = .
----- Original Message -----
From: "Oleg Kobchenko" <olegykj at yahoo.com>
To: "Programming forum" <programming at jsoftware.com>
Sent: Wednesday, January 25, 2006 10:23 PM
Subject: Re: [Jprogramming] Exponentiation with subtraction
With N=12 on 256 Mb limit this solution gives
"limit error".
One solution that I have is better than
x*k^i.N on ts by factors of 7.2 2.1
with N=1000x .
I just thought, for additional bonus point,
the expression would not use any constants
other than the three x,k and N.
--- Roger Hui <RHui000 at shaw.ca> wrote:
> Spoiler solution at the end of msg.
>
>
>
> ----- Original Message -----
> From: "Oleg Kobchenko" <olegykj at yahoo.com>
> To: "Programming forum" <programming at jsoftware.com>
> Sent: Wednesday, January 25, 2006 5:55 PM
> Subject: [Jprogramming] Exponentiation with subtraction
>
> This is a little simple puzzle, so who knew may hold for
> those who actually has to figure it out.
>
> Find an expression for a sequence
>
> x*k^i.N for any real x and positive integers k, N
>
> e.g.
>
> 7.5*5^i.8
> 7.5 37.5 187.5 937.5 4687.5 23437.5 117188 585938
>
> using subtraction (dyadic -) as the only numeric operation.
> That is only structural operations are allowed besides
> constants (i. or @. are OK, x o. or m b. are not).
>
>
>
>
>
>
>
>
>
>
>
>
>
> plus =: [ - 0 - ]
> times=: plus /@$~"0 NB. x+i
> pow =: times/@$~"0 NB. x^i
>
> 7.5 times times/\ 1,7$5
> 7.5 37.5 187.5 937.5 4687.5 23437.5 117188 585938
>
> 7.5 times 5 pow i.8
> 7.5 37.5 187.5 937.5 4687.5 23437.5 117188 585938
More information about the Programming
mailing list