Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,19 @@
|
|||
10 DIM A(100)
|
||||
20 PRINT "First 15 terms:"
|
||||
30 FOR N=0 TO 14: GOSUB 100: PRINT A(N); " ";: NEXT
|
||||
35 PRINT
|
||||
40 PRINT "First repeated term:"
|
||||
50 GOSUB 100
|
||||
55 FOR M=0 TO N-1
|
||||
56 IF A(M)=A(N) THEN 70
|
||||
57 NEXT
|
||||
60 N=N+1: GOTO 50
|
||||
70 PRINT "A(";N;") = ";A(N)
|
||||
80 END
|
||||
100 IF N=0 THEN A(0)=0: RETURN
|
||||
110 X = A(N-1)-N: IF X<0 THEN 160
|
||||
120 FOR M=0 TO N-1
|
||||
130 IF A(M)=X THEN 160
|
||||
140 NEXT
|
||||
150 A(N)=X: RETURN
|
||||
160 A(N)=A(N-1)+N: RETURN
|
||||
30
Task/Recamans-sequence/Minimal-BASIC/recamans-sequence.basic
Normal file
30
Task/Recamans-sequence/Minimal-BASIC/recamans-sequence.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
10 DIM A(100)
|
||||
20 PRINT "FIRST 15 TERMS:"
|
||||
30 FOR N=0 TO 14
|
||||
40 GOSUB 170
|
||||
50 PRINT A(N);" ";
|
||||
60 NEXT N
|
||||
70 PRINT
|
||||
80 PRINT "FIRST REPEATED TERM:"
|
||||
90 GOSUB 170
|
||||
100 FOR M=0 TO N-1
|
||||
110 IF A(M)=A(N) THEN 150
|
||||
120 NEXT M
|
||||
130 LET N=N+1
|
||||
140 GOTO 90
|
||||
150 PRINT "A(";N;") = ";A(N)
|
||||
160 STOP
|
||||
170 IF N=0 THEN 280
|
||||
180 LET X = A(N-1)-N
|
||||
190 IF X<0 THEN 250
|
||||
200 FOR M=0 TO N-1
|
||||
210 IF A(M)=X THEN 250
|
||||
220 NEXT M
|
||||
230 LET A(N)=X
|
||||
240 RETURN
|
||||
250 LET A(N)=A(N-1)+N
|
||||
260 RETURN
|
||||
270 STOP
|
||||
280 LET A(0)=0
|
||||
290 RETURN
|
||||
300 END
|
||||
27
Task/Recamans-sequence/Rust/recamans-sequence.rust
Normal file
27
Task/Recamans-sequence/Rust/recamans-sequence.rust
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use std::collections::HashSet ;
|
||||
|
||||
fn main() {
|
||||
let mut recamans : Vec<i32> = Vec::new( ) ;
|
||||
let mut reca_set : HashSet<i32> = HashSet::new() ;
|
||||
let mut first_nums : HashSet<i32> = HashSet::new( ) ;
|
||||
for i in 0i32..=1000 {
|
||||
first_nums.insert( i ) ;
|
||||
}
|
||||
recamans.push( 0 ) ;
|
||||
reca_set.insert( 0 ) ;
|
||||
let mut current : i32 = 0 ;
|
||||
while ! first_nums.is_subset( &reca_set ) {
|
||||
current += 1 ;
|
||||
let mut nextnum : i32 = recamans[( current as usize ) - 1] - current ;
|
||||
if nextnum < 0 || reca_set.contains( &nextnum ) {
|
||||
nextnum = recamans[(current as usize ) - 1 ] + current ;
|
||||
}
|
||||
recamans.push( nextnum ) ;
|
||||
reca_set.insert( nextnum ) ;
|
||||
if current == 15 {
|
||||
println!("The first 15 numbers of the Recaman sequence are:" ) ;
|
||||
println!("{:?}" , recamans ) ;
|
||||
}
|
||||
}
|
||||
println!("To generate all numbers from 0 to 1000 , one has to go to element {}" , current) ;
|
||||
}
|
||||
26
Task/Recamans-sequence/SETL/recamans-sequence.setl
Normal file
26
Task/Recamans-sequence/SETL/recamans-sequence.setl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
program recaman;
|
||||
a := {[0,0]};
|
||||
|
||||
loop for i in [1..14] do
|
||||
extend(a);
|
||||
end loop;
|
||||
|
||||
print("First 15:", [a(n) : n in [0..14]]);
|
||||
|
||||
loop
|
||||
doing n := extend(a);
|
||||
until #(rept:=[[r,i] : r = a(i) | r=n]) > 1
|
||||
do pass;
|
||||
end loop;
|
||||
|
||||
print("First repetition:", n, "at", {x:x in rept}{n});
|
||||
|
||||
proc extend(rw a);
|
||||
n := max/ domain a;
|
||||
t := a(n) - n-1;
|
||||
if t<0 or t in range a then
|
||||
t := a(n) + n+1;
|
||||
end if;
|
||||
return a(n+1) := t;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue