>i suppose it is obvious, but to get the decimal places before and after the 
>decimal point one can extend tdig to

tdig=:1 :0
:
  NB. b: m, p: x, q: y
  q=. y%x+.y
  (>.m^.(<.x%y)),(>.m^.q)%0=#q-.&q:m
)

eg
   12(3 tdig)3
2 0

>i am still hoping there is less of a circumlocution for getting a verb`s 
>monadic case than ([: verb [)

greg
~krsnadas.org

--

from: Raul Miller <[email protected]>
to: Chat forum <[email protected]>
date: 23 July 2014 16:12
subject: Re: [Jchat] Repeating decimals

Sure... (hopefully I've copied this correctly...):

tdig=:1 :0
:
  NB. b: m, p: x, q: y
  q=. y%x+.y
  (>.m^.q)%0=#q-.&q:m
)

For example,
   12 (10 tdig) 150

--
Raul

Thanks,

--

from: greg heil <[email protected]>
to: Chat forum <[email protected]>
date: 23 July 2014 08:25
subject: Re: [Jchat] Repeating decimals

Raul

Yer right! One can take out the gcd with
 b bq q%p+.q

>The big thing for me though is the circumlocution apparently needed to force 
>the monadic case. Ie ([:q:[) has five characters devoted to just that!-(

Don

>Not yet ready to stand up to that challenge, though i would imagine once the 
>infinite case were filtered it would involve using #. .

greg
~krsnadas.org

--

from: Don Guinn <[email protected]>
to: Chat forum <[email protected]>
date: 23 July 2014 05:23
subject: Re: [Jchat] Repeating decimals

>Why not extend the question a bit? Given p, q and b, how many digits of base b 
>will be required in the repeat? The answer could be an infinite number.

--

from: Raul Miller <[email protected]>
to: Chat forum <[email protected]>
date: 23 July 2014 04:15
subject: Re: [Jchat] Repeating decimals

>OK, rereading the original post, I guess I should assume that we are not only 
>interested in the decimal case.

>That said, I'm not certain that it makes sense to assume that the least common 
>denominator has been factored out of p and q, either.

---
Raul

--

from: greg heil <[email protected]>
to: Chat forum <[email protected]>
date: 22 July 2014 22:28
subject: Re: [Jchat] Repeating decimals

Raul

>Well the way i read Dans query only q and b are important... so if
 bq=:([:q:])-.([:q:[)
then a null result would be finite, eg
 3 bq 3
 10 bq 3
3

greg
~krsnadas.org

--

from: Raul Miller <[email protected]>
reply-to: [email protected]
to: Chat forum <[email protected]>
date: 22 July 2014 20:42
subject: Re: [Jchat] Repeating decimals

That's an interesting point.

>Nevertheless, given the subject line of this thread, I think that maybe the 
>base has already been determined.

Thanks,

---
Raul

--

from: greg heil <[email protected]>
to: Chat forum <[email protected]>
date: 22 July 2014 19:42
subject: Re: [Jchat] Repeating decimals

>What ever formula would also depend on b ... eg the division of 1 by 3 has a 
>finite representation in base 3 of 0.1. (although its representation in base 
>10 is infinite)

greg
~krsnadas.org

--

from: Raul Miller <[email protected]>
to: Chat forum <[email protected]>
date: 22 July 2014 10:18
subject: Re: [Jchat] Repeating decimals

 $p(2 5-.~[:q:]%+.)q
0

>Assuming p and q are rank 0, of course. (And this is a reasonable assumption, 
>since the problem statement suggests no use for dimensions).

Thanks,

---
Raul

--

from: Dan Bron <[email protected]>
to: [email protected]
date: 22 July 2014 08:25
subject: [Jchat] Repeating decimals

>Given 3 positive integers p,q and b, where p and q represent the numerator and 
>denominator of a rational number (respectively), and b a numerical base (or 
>radix), how can we know if p%q has a finite (or not) representation in b?

>In other words, if p%q can be represented by a finite 
>(non-infinitely-repeating) decimal in base b, then what do we know about the 
>relationship of p to q or p%q to b ?

>You may allow p to take on the value 0 if needed for generality, but q is 
>strictly > 0 (obviously) and b is strictly > 1 (probably?).

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to