fareylen

fareylen — returns the length of a Farey Sequence.

Description

This opcode can be used in conjunction with GENfarey. It calculates the length of Farey Sequence Fn. Its length is given by: |Fn| = 1 + SUM over n phi(m) where phi(m) is Euler's totient function, which gives the number of integers ≤ m that are coprime to m.

Some values for the length of Fn given n:

n Fn
1 2
2 3
3 5
4 7
5 11
6 13
7 19
8 23
9 29
10 33
11 43
12 47
13 59
14 65
15 73
16 81
17 97
18 103
19 121
20 129

Syntax

kfl fareylen kfn

Performance

The length of the identified Farey sequence is returned.

kfn -- Integer identifying the sequence.

Examples

Here is an example of the fareylen opcode. It uses the file fareylen.csd.

Example 295. Example of the fareylen opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
-n
</CsOptions>
<CsInstruments>

sr=44100
ksmps=32
nchnls=1

; by Stefano Cucchi and Menno Knevel - 2024

instr 10

kfarnf randomi 1, 10, 4
kfarn ceil kfarnf

klenght fareylen kfarn  
printks "farey length of %d = %d\n",.1,  kfarn, klenght

endin

</CsInstruments>
<CsScore>

i 10 0 3
e
</CsScore>
</CsoundSynthesizer> 


See Also

Models and Emulations

Credits

Author: Georg Boenn
University of Glamorgan, UK

New in Csound version 5.13