NB. prime or prime power nearest to y
NB. prime power must be power of x or higher
NB. default for x is 2
pp=: 2&$: : (4 : 0)
 c=. ({. + [EMAIL PROTECTED]@(-/)) _4 4 p:"0 y                NB. candidate 
integers
 e=. 2+i._1+<.x^.{:c                              NB. possible exponents 
excluding 1
 p=. e <[EMAIL PROTECTED]:/ c                                   NB. possible 
prime bases
 b=. (1 p:"0 c) +. +./(x<:p)*.(1 p: p)*.c="1 p^e  NB. mask for primes & prime 
powers
 y ((i.<./)@:|@:- { ]) b#c
)

   pp 63
64
   3 pp 63
61
   
   ] n=: 2^100x
1267650600228229401496703205376
   pp n
1267650600228229401496703205376
   3 pp n
1267650600228229401496703205361

A tacit version of this solution is left as an
exercise for the reader.



----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Thursday, September 21, 2006 12:31 pm
Subject: Re: [Jprogramming] Explicit to Tacit - newbie question

> j=. _4 4 p:"0 n are the integers that need to be
> considered.  If m (here m=.3) is the smallest prime
> whose powers are in the running, then the highest
> possible exponent is <.m^.{:j .  The problem is 
> manageable.


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

Reply via email to