Safe and Sophie Germain primes: Difference between revisions

Add Refal
(Add 8080 Assembly)
(Add Refal)
Line 915:
683 719 743 761 809 911 953 1013 1019 1031
1049 1103 1223 1229 1289 1409 1439 1451 1481 1499</pre>
 
=={{header|Refal}}==
<syntaxhighlight>$ENTRY Go {
= <Table (10 6) <Gen 50 SophieGermain>>;
};
 
Cell {
s.CW s.N, <Repeat s.CW ' '> <Symb s.N>: e.R,
<Last s.CW e.R>: (e.X) e.C = e.C;
};
 
Repeat {
0 s.I = ;
s.N s.I = s.I <Repeat <- s.N 1> s.I>;
};
 
Table {
(s.W s.CW) = ;
(s.W s.CW) e.X, <First s.W e.X>: (e.Row) e.Rest =
<Prout <Each (Cell s.CW) e.Row>>
<Table (s.W s.CW) e.Rest>;
};
 
Gen {
s.N s.F = <Gen s.N s.F 1>;
0 s.F s.I = ;
s.N s.F s.I, <Mu s.F s.I>: {
True = s.I <Gen <- s.N 1> s.F <+ s.I 1>>;
False = <Gen s.N s.F <+ s.I 1>>;
};
};
 
SophieGermain {
s.N, <+ 1 <* 2 s.N>>: s.Safe = <And <Prime s.N> <Prime s.Safe>>;
};
 
Prime {
s.N, <Compare s.N 2>: '-' = False;
s.N = <Prime s.N 2>;
s.N s.D, <Compare s.N <* s.D s.D>>: '-' = True;
s.N s.D, <Mod s.N s.D>: 0 = False;
s.N s.D = <Prime s.N <+ s.D 1>>;
};
 
And {
True True = True;
s.X s.Y = False;
};
 
Each {
(e.F) = ;
(e.F) s.I e.X = <Mu e.F s.I> <Each (e.F) e.X>;
};</syntaxhighlight>
{{out}}
<pre> 2 3 5 11 23 29 41 53 83 89
113 131 173 179 191 233 239 251 281 293
359 419 431 443 491 509 593 641 653 659
683 719 743 761 809 911 953 1013 1019 1031
1049 1103 1223 1229 1289 1409 1439 1451 1481 1499</pre>
 
=={{header|Ring}}==
2,119

edits