Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,76 @@
|
|||
PROC Generate(BYTE ARRAY seq INT POINTER count INT minCount,maxVal)
|
||||
INT i
|
||||
|
||||
seq(0)=1 seq(1)=1 count^=2 i=1
|
||||
WHILE count^<minCount OR seq(count^-1)#maxVal AND seq(count^-2)#maxVal
|
||||
DO
|
||||
seq(count^)=seq(i-1)+seq(i)
|
||||
seq(count^+1)=seq(i)
|
||||
count^==+2 i==+1
|
||||
OD
|
||||
RETURN
|
||||
|
||||
PROC PrintSeq(BYTE ARRAY seq INT count)
|
||||
INT i
|
||||
|
||||
PrintF("First %I items:%E",count)
|
||||
FOR i=0 TO count-1
|
||||
DO
|
||||
PrintB(seq(i)) Put(32)
|
||||
OD
|
||||
PutE() PutE()
|
||||
RETURN
|
||||
|
||||
PROC PrintLoc(BYTE ARRAY seq INT seqCount
|
||||
BYTE ARRAY loc INT locCount)
|
||||
INT i,j
|
||||
BYTE value
|
||||
|
||||
FOR i=0 TO locCount-1
|
||||
DO
|
||||
j=0 value=loc(i)
|
||||
WHILE seq(j)#value
|
||||
DO
|
||||
j==+1
|
||||
OD
|
||||
PrintF("%B appears at position %I%E",value,j+1)
|
||||
OD
|
||||
PutE()
|
||||
RETURN
|
||||
|
||||
BYTE FUNC Gcd(BYTE a,b)
|
||||
BYTE tmp
|
||||
|
||||
IF a<b THEN
|
||||
tmp=a a=b b=tmp
|
||||
FI
|
||||
|
||||
WHILE b#0
|
||||
DO
|
||||
tmp=a MOD b
|
||||
a=b b=tmp
|
||||
OD
|
||||
RETURN (a)
|
||||
|
||||
PROC PrintGcd(BYTE ARRAY seq INT count)
|
||||
INT i
|
||||
|
||||
FOR i=0 TO count-2
|
||||
DO
|
||||
IF Gcd(seq(i),seq(i+1))>1 THEN
|
||||
PrintF("GCD between %I and %I item is greater than 1",i+1,i+2)
|
||||
RETURN
|
||||
FI
|
||||
OD
|
||||
Print("GCD between all two consecutive items of the sequence is equal 1")
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
BYTE ARRAY seq(2000),loc=[1 2 3 4 5 6 7 8 9 10 100]
|
||||
INT count
|
||||
|
||||
Generate(seq,@count,1000,100)
|
||||
PrintSeq(seq,15)
|
||||
PrintLoc(seq,count,loc,11)
|
||||
PrintGcd(seq,1000)
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue