Re: Is there a function that returns factors?

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 28 2011 - 16:44:36 MDT

Hi Bridget,
I don't believe one exists, but you can create your own. Something like
this would work. (You need to load contributed.ncl to use mod.)

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
a = 56
blist = ispan(1,a,1)
d = ind(mod(a,blist).eq.0)+1
print(d)

Good luck,
Adam

On 03/28/2011 03:28 PM, Bridget Thrasher wrote:
> I'm wondering if there is a function that, when given an integer, would
> return that number's factors. For example, if you had x =
> find_factors(56), x would then be the array (/1,2,4,7,8,14,28,56/). Does
> such a thing exist?
>
> -Bridget
>
> --
> Bridget Thrasher, PhD
> Independent Contractor, Research Scientist
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
__________________________________________________
Adam Phillips 
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Mar 28 16:44:40 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:01:21 MDT