Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -7,7 +7,7 @@ val .farey = f(.n) {
|
|||
}
|
||||
}
|
||||
|
||||
val .testFarey = f() {
|
||||
val .testFarey = impure f() {
|
||||
writeln "Farey sequence for orders 1 through 11"
|
||||
for .i of 11 {
|
||||
writeln $"\.i:2;: ", join " ", map(f $"\.f[1];/\.f[2];", .farey(.i))
|
||||
|
|
|
|||
32
Task/Farey-sequence/MATLAB/farey-sequence.m
Normal file
32
Task/Farey-sequence/MATLAB/farey-sequence.m
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
clear all;close all;clc;
|
||||
|
||||
% Print Farey sequences for 1 to 11
|
||||
for i = 1:11
|
||||
farey_sequence = farey(i);
|
||||
fprintf('%2d: %s\n', i, strjoin(farey_sequence, ' '));
|
||||
end
|
||||
fprintf('\n');
|
||||
|
||||
% Print the number of fractions in Farey sequences for 100 to 1000 step 100
|
||||
for i = 100:100:1000
|
||||
farey_sequence = farey(i);
|
||||
fprintf('%4d: %6d fractions\n', i, length(farey_sequence));
|
||||
end
|
||||
|
||||
function farey_sequence = farey(n)
|
||||
a = 0;
|
||||
b = 1;
|
||||
c = 1;
|
||||
d = n;
|
||||
farey_sequence = {[num2str(a) '/' num2str(b)]}; % Initialize the sequence with "0/1"
|
||||
while c <= n
|
||||
k = fix((n + b) / d);
|
||||
aa = a;
|
||||
bb = b;
|
||||
a = c;
|
||||
b = d;
|
||||
c = k * c - aa;
|
||||
d = k * d - bb;
|
||||
farey_sequence{end+1} = [num2str(a) '/' num2str(b)]; % Append the fraction to the sequence
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue