Enigmatic Code

Programming Enigma Puzzles

Enigma 1587: Déjà vu

From New Scientist #2752, 20th March 2010 [link]

I have in mind a number N. I’ll tell you some things about it:

It is more than 2. If you draw a figure with that number of straight sides, with all its angles the same and with all the vertices lying on a circle, then all the sides will be equal in length. And the angles will be whole numbers of degrees.

And how many of the numbers 1, 2, 3,… , N divide exactly into N? I’ve worked out that number and I’ll tell you something about it:

It is more than 2. If you draw a figure with that number of straight sides, with all its angles the same, and with all the vertices lying on a circle, then all the sides will be equal in length. And the angles will be whole numbers of degrees.

What is N?

[enigma1587]

Advertisements

One response to “Enigma 1587: Déjà vu

  1. jimrandell 29 January 2012 at 11:23 am

    The following Python program runs in 33ms.

    # we're looking at regular polygons with odd numbers of sides
    # (even numbers of sides don't have to be equal length)
    
    from enigma import irange, printf
    
    x = dict()
    for N in irange(3, 360, step=2):
      # compute the angle
      (d, r) = divmod(360, N)
      if r > 0: continue
      a = 180 - d
      # and the number of divisors
      n = 2
      for i in irange(2, N - 1):
        if N % i == 0: n += 1
      x[N] = (a, n)
    
    for (N, (a, f)) in x.items():
      if not(f > 2 and f in x): continue
      printf("N={N} angle={a} factors={f}")
    

    Solution: N = 9.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: