Skip to content

Commit

Permalink
docs: added example for shor's algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Russak committed Nov 25, 2023
1 parent 37e4931 commit bd0592b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test.lum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ asVar = fn gdc2(a, b) {
};
a
};

fn shor(x) {
a = 2;
while (a < x) {
if (gdc(a,x) == 1) {
b = a;
while (b < x) {
if (gdc(b,x) == 1) {
if (a*b % x == 1) {
return 'p=' + a + ' q=' + b;
};
};
b = b + 1;
};
};
a = a + 1;
};
''
};

/*
lambda = |a, b| {
while(b!=0) {
Expand All @@ -28,5 +48,6 @@ x = 21;
y = 49;
print("gdc("+x+","+y+") = " + gdc(x,y));
print("asVar("+x+","+y+") = " + asVar(x,y));
print("shor(15) = " + shor(15));
// print("lambda("+x+","+y+") = " + lambda(x,y));
0

0 comments on commit bd0592b

Please sign in to comment.