# Is there a pattern behind the numbers of sharp keys in chromatic scale

Here are the keys of the chromatic scale containing 12 pitches:

```| C | C# | D | D# | E | F | F# | G | G# | A | A# |  B |
|---+----+---+----+---+---+----+---+----+---+----+----+
| 0 |  1 | 2 |  3 | 4 | 5 |  6 | 7 |  8 | 9 | 10 | 11 |
```

The sharp keys have numbers:

``````| Key   |           1 | 3 | 6 | 8 | 10 | 13 (C#) |
|-------+-------------+---+---+---+----+---------|
| Delta | 3 (prev A#) | 2 | 3 | 2 |  2 |       3 |
``````

Why are the pitches with these numbers specifically called "sharp" or "flat"?

Is there any mathematical pattern behind it or it's just a historical coincidence?

• Aren't you in effect asking why the major scale uses numbers `0 2 4 5 7 9 11`, instead, for example, `0 2 3 5 7 8 10` (a minor scale pattern)? – hpaulj Sep 2 '15 at 21:12
• @hpaulj Yeah, why does it use these numbers? Very interesting. Why is the first sequence big (major) and the second - small (minor)? – user4035 Sep 3 '15 at 2:16
• Don't think of 'major/minor' as 'big/small'. Don't read too much into the names; they are more historical convensions than anything else. Look at en.wikipedia.org/wiki/Mode_(music)#Modern to see how they fit in a bigger picture of `modes`. – hpaulj Sep 3 '15 at 5:06

## 4 Answers

Yes, there is a pattern. The initial starting point is the following two facts:

• Traditionally, the western musical scale was based on a 7-note scale, named A-G.
• Acoustically, the most basic harmony, aside from unisons and octaves, is the perfect fifth (P5), which can be very closely approximated by 7/12ths of an octave (where each 12th of an octave is called a half-step, H).

In order to maximize the occurrence of P5's, the scale is constructed so that each of the seven notes in the scale is a P5 away from another note. Since pitches "wrap around" at the octave, we use so-called "modular arithmetic" (think of adding clock times, where 11:00 + 2 hours = 1:00), denoted below by the notation "mod12". If we start from F (which happens to be 5 in your numbering scheme), and add a P5 (7 half steps) each time, this gives us the following sequence of notes:

• F = 5
• C = F+P5 = 5+7 mod12 = 0
• G = C+P5 = 0+7 mod12 = 7
• D = G+P5 = 7+7 mod12 = 2
• A = D+P5 = 2+7 mod12 = 9
• E = A+P5 = 9+7 mod12 = 4
• B = E+P5 = 4+7 mod12 = 11

This then, gives us the patterns of the non-sharp and non-flat notes. You'll notice, however, that from B back to F is a distance of 6 not 7, which corresponds to a dissonant interval called the tritone, instead of a P5. In order to address this, you have two choices: You can either replace the B with a note a P5 below F:

• B♭ = F-P5 = 5-7 mod12 = 10 = B-1

Or you can replace the F with a note a P5 above B:

• F♯ = B+P5 = 11+7 mod12 = 6 = F+1

Note that these new notes replace the original, and are either a half step below or above the note that they replace. Also note that this pattern can then be continued on indefinitely, by adding or subtracting 7 (mod12) to get the next note in the sequence.

Update: If you extrapolate and generalize the above sequence, you'll notice that any pitch can be represented by the formula:

(5 + n*7) mod 12

In this formula, the value of n tells you two important things about how this pitch is named.

• If you divide n by 7, the integer part of the division (technically, the floor) tells you how many sharps (positive) or flats (negative) the note has. For example, if n is in the range 0..6, floor(n/7) = 0 and you get the plain note names listed above. If n is in the range 7..13 (floor(n/7) = 1), you get names with single sharps. In the range 14..20 (floor(n/7) = 2), you get double sharps. In the range -7..-1 (floor(n/7) = -1), you get flats.
• The remainder of dividing n/7 gives you a number from 0-6, which gives you the letter name in the order (F, C, G, D, A, E, B).

As you point out in the comments, this sequence will eventually repeat, since it is modular arithmetic. Indeed, this is true, and it reflects a very important fact about our musical system: no note has a single unique name, but rather can be expressed using any number of different names (note names to pitches are not a one-to-one function). For example, all of the following pitch names map to the same pitch class:

• F = 5
• E♯ = (5 + 12*7) mod12 = 5
• D♯♯♯ = (5 + 24*7) mod12 = 5
• C♯♯♯♯♯ = (5 + 36*7) mod12 = 5
• G♭♭ = (5 - 12*7) mod12 = 5
• A♭♭♭♭ = (5 - 24*7) mod12 = 5

Thus, as you can see, all pitches can technically be described as a sharp or a flat. However, there will also exist a non-sharp and non-flat note name only in the case where the pitch number can be expressed with an n such that floor(n/7) == 0 (in other words, n is in the range 0..6).

• "this pattern can then be continued on indefinitely, by adding or subtracting 7 (mod12) to get the next note in the sequence." - yeah, but it will repeat itself as it's a modular arithmetics. – user4035 Sep 2 '15 at 8:54
• Can we use another numbering not to start from 5? I want to get a formula for sharp and non-sharp notes. – user4035 Sep 2 '15 at 8:54
• It's mildy curious that the circle of fifths has to start at `F` to get the 7 `natural` notes, even though `C` is the root of the corresponding Major scale. In a sense the circle fits the Lydian (F) mode better than the Ionian (C). – hpaulj Sep 3 '15 at 22:18
• @hpaulj I found the formula. You need to get f(x) = (x - 5) * 7 mod 12. If f(x) <= 6, the note is non-sharp. Otherwise it's sharp. x >= 0 and x <= 11. – user4035 Sep 6 '15 at 6:45

A somewhat simpler answer, for us mere mortals. Write the note names around in a circle, as in the numbers on a clock face, in the same order that you did earlier. C can go anywhere - I put it at 12 o'clock. Start at C (no # or b), and count clockwise 7. You get to G. 1#. Go another 7, you get to D. 2#. And so on. Now back to C, this time count anti-clockwise 7. You get F. 1b. On another 7, you get Bb. 2b. Obviously (?) the Bb isn't going to be called A#, because we're now in flat territory. How you make this into an equation is up to you, the mathematician!

• Here's a picture: circle-of-fifths.net/images/circle-of-fifths.gif. There's a key at 6:00 that has two possible names, G flat or F#. But except for that one, there is a clear convention for whether to write the key signature with sharps or with flats so that you don't end up with more than 7 sharps or flats in the key signature. – aparente001 Sep 2 '15 at 13:18

Here's a 'formula' for finding the natural and sharp notes, expressed as Python/numpy calculations (MATLAB would do just as well). It's not a refined calculation, just an easy way to generate the numbers and group them (mixing arrays, sets and sorted lists).

``````i = np.arange(5,200,7)  # numbers from 5 up, stepping by 7

natural = set((i%12)[:7])  # modulus by 12; 1st set of 7
# set([0, 2, 4, 5, 7, 9, 11])

next = set((i%12)[7:14])  # 2nd set
# set([0, 1, 3, 5, 6, 8, 10])

sharps = sorted(set(next-natural)   # remove the naturals
# [1, 3, 6, 8, 10]
``````

Naturals are the 1st set of 7, sharps are the 2nd set, minus the ones we already identified as naturals (0 and 5).

If I start the count with `0`,

``````naturals: [0, 2, 4, 6, 7, 9, 11])
sharps: [1, 3, 5, 8, 10]
``````

In effect, `F G A B C D E` and `F# G# A# C# D#`.

So I can start the count anywhere, but the location of the half steps in the natural scale will shift.

https://en.wikipedia.org/wiki/Mode_(music)#Summary - describes this connection between modes and the circle.

Using your formula

`````` f(x) = (x - 5) * 7 mod 12.
If f(x) <= 6, the note is non-sharp.
Otherwise it's sharp.
x >= 0 and x <= 11.

In : x=np.arange(0,12)
In : fx=((x-5)*7)%12

In : x[~(fx<7)]  # the sharps
Out: array([ 1,  3,  6,  8, 10])

In : x[fx<7]  # the naturals
Out: array([ 0,  2,  4,  5,  7,  9, 11])
``````

The 7&12 are producing the circular pattern of `TTSTTTS`; the 5 is anchoring it to the Ionian (CMajor) mode.

• I'll need to read it carefully to comprehend. – user4035 Sep 4 '15 at 7:47

The previous answers are good, but I think it's also musically significant that since sharps are added through the cycle of fifths means that what you're calling the "sharp keys", taken together form a pentatonic scale. Specifically C#, D#, F#, G#, and A# form the F# major pentatonic scale.