Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
144
Task/Leonardo-numbers/AArch64-Assembly/leonardo-numbers.aarch64
Normal file
144
Task/Leonardo-numbers/AArch64-Assembly/leonardo-numbers.aarch64
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program numvinci64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 64 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
szMessErreur: .asciz "Error !!!\n"
|
||||
szMessVinci: .asciz "Leonardo numbers :\n"
|
||||
szMessFibo: .asciz "\nFibonaci numbers :\n"
|
||||
|
||||
.align 4
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
.align 4
|
||||
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrszMessDebutPgm
|
||||
bl affichageMess // start message
|
||||
|
||||
ldr x0,qAdrszMessVinci
|
||||
bl affichageMess
|
||||
mov x0,#0 // rank
|
||||
mov x1,#1 // L(0) or L(n-2)
|
||||
mov x2,#1 // L(1) or L(n-1)
|
||||
mov x3,#1 // addition
|
||||
mov x4,#25 // maxi
|
||||
bl genererVinci
|
||||
|
||||
ldr x0,qAdrszMessFibo
|
||||
bl affichageMess
|
||||
mov x0,#0
|
||||
mov x1,#0
|
||||
mov x2,#1
|
||||
mov x3,#0
|
||||
mov x4,#25
|
||||
bl genererVinci
|
||||
|
||||
|
||||
|
||||
ldr x0,qAdrszMessFinOK
|
||||
bl affichageMess
|
||||
b 100f
|
||||
99:
|
||||
ldr x0,qAdrszMessErreur // error
|
||||
bl affichageMess
|
||||
mov x0, #1 // return code error
|
||||
b 100f
|
||||
100:
|
||||
mov x8,EXIT
|
||||
svc #0 // system call
|
||||
qAdrszMessDebutPgm: .quad szMessDebutPgm
|
||||
qAdrszMessFinOK: .quad szMessFinOK
|
||||
qAdrszMessErreur: .quad szMessErreur
|
||||
qAdrsZoneConv: .quad sZoneConv
|
||||
qAdrszMessVinci: .quad szMessVinci
|
||||
qAdrszMessFibo: .quad szMessFibo
|
||||
/***************************************************/
|
||||
/* Generation random number */
|
||||
/***************************************************/
|
||||
/* x0 contains n */
|
||||
/* x1 contains L(0) */
|
||||
/* x2 contains L(1) */
|
||||
/* x3 contains addition */
|
||||
/* x4 contains limit number */
|
||||
genererVinci:
|
||||
stp x5,lr,[sp,-16]!
|
||||
stp x6,x7,[sp,-16]!
|
||||
mov x6,x0
|
||||
cmp x4,#0 // end compute ?
|
||||
ble 100f
|
||||
cmp x0,#0 // L(0) ?
|
||||
bne 1f
|
||||
mov x0,x1
|
||||
bl displayNumber
|
||||
add x0,x6,#1 // increment rank
|
||||
sub x4,x4,#1 // decrement counter
|
||||
bl genererVinci
|
||||
b 100f
|
||||
1:
|
||||
cmp x0,#1 // L(1) ?
|
||||
bne 2f
|
||||
mov x0,x2
|
||||
bl displayNumber
|
||||
add x0,x6,#1
|
||||
sub x4,x4,#1
|
||||
bl genererVinci
|
||||
b 100f
|
||||
2:
|
||||
add x5,x2,x1 // add L(n-2) L(n-1)
|
||||
add x5,x5,x3 // add addition
|
||||
mov x0,x5
|
||||
bl displayNumber
|
||||
add x0,x6,#1
|
||||
sub x4,x4,#1
|
||||
mov x1,x2 // L(n-1) -> L(n-2)
|
||||
mov x2,x5 // number -> L(n-1)
|
||||
bl genererVinci
|
||||
b 100f
|
||||
|
||||
100:
|
||||
ldp x6,x7,[sp],16 // end function
|
||||
ldp x5,lr,[sp],16
|
||||
ret
|
||||
/***************************************************/
|
||||
/* display number */
|
||||
/***************************************************/
|
||||
/* x0 contains number */
|
||||
displayNumber:
|
||||
stp x1,lr,[sp,-16]!
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10
|
||||
ldr x0,qAdrsZoneConv
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
100:
|
||||
ldp x1,lr,[sp],16
|
||||
ret
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeARM64.inc"
|
||||
|
|
@ -20,23 +20,24 @@ BEGIN
|
|||
print( ( whole( l0, 0 ), " " ) );
|
||||
IF n > 1 THEN
|
||||
print( ( whole( l1, 0 ), " " ) );
|
||||
INT lp := l0;
|
||||
INT ln := l1;
|
||||
INT prev ln := l0;
|
||||
INT curr ln := l1;
|
||||
FROM 2 TO n - 1 DO
|
||||
INT next = ln + lp + add number;
|
||||
lp := ln;
|
||||
ln := next;
|
||||
print( ( whole( ln, 0 ), " " ) )
|
||||
INT next = curr ln + prev ln + add number;
|
||||
prev ln := curr ln;
|
||||
curr ln := next;
|
||||
print( ( whole( curr ln, 0 ), " " ) )
|
||||
OD
|
||||
FI
|
||||
FI # show # ;
|
||||
|
||||
# first series #
|
||||
print( ( "First 25 Leonardo numbers", newline ) );
|
||||
show( 25, leonardo numbers );
|
||||
print( ( newline ) );
|
||||
show( 25, leonardo numbers ); print( ( newline ) );
|
||||
# second series #
|
||||
print( ( "First 25 Leonardo numbers from 0, 1 with add number = 0", newline ) );
|
||||
show( 25, leonardo numbers WITHLZERO 0 WITHADDNUMBER 0 );
|
||||
print( ( newline ) )
|
||||
show( 25, leonardo numbers WITHLZERO 0 WITHADDNUMBER 0 ); print( ( newline ) );
|
||||
# additional test to ensure WITHLONE is used #
|
||||
print( ( "First 25 Leonardo numbers from 0, 2 with add number = 2", newline ) );
|
||||
show( 25, leonardo numbers WITHLONE 2 WITHADDNUMBER 2 ); print( ( newline ) )
|
||||
END
|
||||
|
|
|
|||
143
Task/Leonardo-numbers/ARM-Assembly/leonardo-numbers.arm
Normal file
143
Task/Leonardo-numbers/ARM-Assembly/leonardo-numbers.arm
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program numvinci.s */
|
||||
|
||||
/* REMARK 1 : this program use routines in a include file
|
||||
see task Include a file language arm assembly
|
||||
for the routine affichageMess conversion10
|
||||
see at end of this program the instruction include */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
.include "../constantes.inc"
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 32 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
szMessErreur: .asciz "Error !!!\n"
|
||||
szMessVinci: .asciz "Leonardo numbers :\n"
|
||||
szMessFibo: .asciz "\nFibonaci numbers :\n"
|
||||
|
||||
.align 4
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
.align 4
|
||||
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr r0,iAdrszMessDebutPgm
|
||||
bl affichageMess @ start message
|
||||
|
||||
ldr r0,iAdrszMessVinci
|
||||
bl affichageMess
|
||||
mov r0,#0 @ rank
|
||||
mov r1,#1 @ L(0) or L(n-2)
|
||||
mov r2,#1 @ L(1) or L(n-1)
|
||||
mov r3,#1 @ addition
|
||||
mov r4,#25 @ maxi
|
||||
bl genererVinci
|
||||
|
||||
ldr r0,iAdrszMessFibo
|
||||
bl affichageMess
|
||||
mov r0,#0
|
||||
mov r1,#0
|
||||
mov r2,#1
|
||||
mov r3,#0
|
||||
mov r4,#25
|
||||
bl genererVinci
|
||||
|
||||
|
||||
|
||||
ldr r0,iAdrszMessFinOK
|
||||
bl affichageMess
|
||||
b 100f
|
||||
99:
|
||||
ldr r0,iAdrszMessErreur @ error
|
||||
bl affichageMess
|
||||
mov r0, #1 @ return code error
|
||||
b 100f
|
||||
100:
|
||||
mov r7,#EXIT @ program end
|
||||
svc #0 @ system call
|
||||
iAdrszMessDebutPgm: .int szMessDebutPgm
|
||||
iAdrszMessFinOK: .int szMessFinOK
|
||||
iAdrszMessErreur: .int szMessErreur
|
||||
iAdrsZoneConv: .int sZoneConv
|
||||
iAdrszMessVinci: .int szMessVinci
|
||||
iAdrszMessFibo: .int szMessFibo
|
||||
/***************************************************/
|
||||
/* Generation random number */
|
||||
/***************************************************/
|
||||
/* r0 contains n */
|
||||
/* r1 contains L(0) */
|
||||
/* r2 contains L(1) */
|
||||
/* r3 contains addition */
|
||||
/* r4 contains limit number */
|
||||
genererVinci:
|
||||
push {r5,r6,lr} @ save registers
|
||||
mov r6,r0
|
||||
cmp r4,#0 @ end compute ?
|
||||
ble 100f
|
||||
cmp r0,#0 @ L(0) ?
|
||||
bne 1f
|
||||
mov r0,r1
|
||||
bl displayNumber
|
||||
add r0,r6,#1 @ increment rank
|
||||
sub r4,r4,#1 @ decrement counter
|
||||
bl genererVinci
|
||||
b 100f
|
||||
1:
|
||||
cmp r0,#1 @ L(1) ?
|
||||
bne 2f
|
||||
mov r0,r2
|
||||
bl displayNumber
|
||||
add r0,r6,#1
|
||||
sub r4,r4,#1
|
||||
bl genererVinci
|
||||
b 100f
|
||||
2:
|
||||
add r5,r2,r1 @ add L(n-2) L(n-1)
|
||||
add r5,r3 @ add addition
|
||||
mov r0,r5
|
||||
bl displayNumber
|
||||
add r0,r6,#1
|
||||
sub r4,r4,#1
|
||||
mov r1,r2 @ L(n-1) -> L(n-2)
|
||||
mov r2,r5 @ number -> L(n-1)
|
||||
bl genererVinci
|
||||
b 100f
|
||||
|
||||
100: @ end function
|
||||
pop {r5,r6,pc} @ restaur registers
|
||||
/***************************************************/
|
||||
/* display number */
|
||||
/***************************************************/
|
||||
/* r0 contains number */
|
||||
displayNumber:
|
||||
push {r1,lr} @ save registers
|
||||
ldr r1,iAdrsZoneConv
|
||||
bl conversion10
|
||||
ldr r0,iAdrsZoneConv
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
100:
|
||||
pop {r1,pc} @ restaur registers
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
.include "../affichage.inc"
|
||||
26
Task/Leonardo-numbers/Asymptote/leonardo-numbers.asymptote
Normal file
26
Task/Leonardo-numbers/Asymptote/leonardo-numbers.asymptote
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
void leonardo(int L0, int L1, int suma, string texto) {
|
||||
int limit = 25;
|
||||
int tmp, l0 = L0, l1 = L1;
|
||||
write("Numeros de ", texto, suffix=none);
|
||||
write(" (", L0, suffix=none);
|
||||
write(",", L1, suffix=none);
|
||||
write(",", suma, suffix=none);
|
||||
write("):");
|
||||
for (int i = 1; i <= limit; ++i) {
|
||||
if (i == 1)
|
||||
write(" ", l0, suffix=none);
|
||||
else if (i == 2)
|
||||
write(" ", l1, suffix=none);
|
||||
else {
|
||||
write(" ", l0 + l1 + suma, suffix=none);
|
||||
tmp = l0;
|
||||
l0 = l1;
|
||||
l1 = tmp + l1 + suma;
|
||||
}
|
||||
}
|
||||
write("");
|
||||
write("");
|
||||
}
|
||||
|
||||
leonardo(1, 1, 1, "Leonardo");
|
||||
leonardo(0, 1, 0, "Fibonacci");
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
call leonardo(1,1,1,"Leonardo")
|
||||
call leonardo(0,1,0,"Fibonacci")
|
||||
end
|
||||
|
||||
subroutine leonardo(L0, L1, suma, texto)
|
||||
print "Numeros de " + texto + " (" + L0 + "," + L1 + "," + suma + "):"
|
||||
for i = 1 to 25
|
||||
|
|
@ -16,8 +20,3 @@ subroutine leonardo(L0, L1, suma, texto)
|
|||
next i
|
||||
print chr(10)
|
||||
end subroutine
|
||||
|
||||
#--- Programa Principal ---
|
||||
call leonardo(1,1,1,"Leonardo")
|
||||
call leonardo(0,1,0,"Fibonacci")
|
||||
end
|
||||
|
|
|
|||
46
Task/Leonardo-numbers/COBOL/leonardo-numbers.cobol
Normal file
46
Task/Leonardo-numbers/COBOL/leonardo-numbers.cobol
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Leonardo_numbers.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 LIMITE PIC 99 VALUE 25.
|
||||
01 L0 PIC 99(5).
|
||||
01 L1 PIC 99(5).
|
||||
01 SUMA PIC 99(5).
|
||||
01 TMP PIC 99(5).
|
||||
01 I PIC 99.
|
||||
01 TEXTO PIC X(9).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MOVE 1 TO L0
|
||||
MOVE 1 TO L1
|
||||
MOVE 1 TO SUMA
|
||||
MOVE "Leonardo" TO TEXTO
|
||||
PERFORM DISPLAY-NUMBERS
|
||||
|
||||
MOVE 0 TO L0
|
||||
MOVE 1 TO L1
|
||||
MOVE 0 TO SUMA
|
||||
MOVE "Fibonacci" TO TEXTO
|
||||
PERFORM DISPLAY-NUMBERS
|
||||
|
||||
STOP RUN.
|
||||
|
||||
DISPLAY-NUMBERS.
|
||||
DISPLAY "Numeros de " TEXTO " (" L0 "," L1 "," SUMA "):"
|
||||
PERFORM VARYING I FROM 1 BY 1 UNTIL I > LIMITE
|
||||
IF I = 1 THEN
|
||||
DISPLAY " " L0 WITH NO ADVANCING
|
||||
ELSE IF I = 2 THEN
|
||||
DISPLAY " " L1 WITH NO ADVANCING
|
||||
ELSE
|
||||
COMPUTE TMP = L0 + L1 + SUMA
|
||||
DISPLAY " " TMP WITH NO ADVANCING
|
||||
MOVE L0 TO TMP
|
||||
MOVE L1 TO L0
|
||||
ADD TMP TO L1 GIVING L1
|
||||
ADD SUMA TO L1
|
||||
END-IF
|
||||
END-PERFORM
|
||||
DISPLAY " "
|
||||
.
|
||||
21
Task/Leonardo-numbers/Chipmunk-Basic/leonardo-numbers.basic
Normal file
21
Task/Leonardo-numbers/Chipmunk-Basic/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
100 sub leonardo(l0,l1,suma,texto$)
|
||||
110 print "Numeros de ";texto$;" (";l0;",";l1;",";suma;"):"
|
||||
120 for i = 1 to limit
|
||||
130 if i = 1 then
|
||||
140 print l0;
|
||||
150 else
|
||||
160 if i = 2 then
|
||||
170 print l1;
|
||||
180 else
|
||||
190 print l0+l1+suma;
|
||||
200 tmp = l0
|
||||
210 l0 = l1
|
||||
220 l1 = tmp+l1+suma
|
||||
230 endif
|
||||
240 endif
|
||||
250 next i
|
||||
260 print chr$(10)
|
||||
270 end sub
|
||||
280 limit = 25
|
||||
290 leonardo(1,1,1,"Leonardo")
|
||||
300 leonardo(0,1,0,"Fibonacci")
|
||||
16
Task/Leonardo-numbers/Dart/leonardo-numbers.dart
Normal file
16
Task/Leonardo-numbers/Dart/leonardo-numbers.dart
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
void leoN(int cnt, {int l0 = 1, int l1 = 1, int add = 1}) {
|
||||
int t;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
print('$l0 ');
|
||||
t = l0 + l1 + add;
|
||||
l0 = l1;
|
||||
l1 = t;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
print('Leonardo Numbers: ');
|
||||
leoN(25);
|
||||
print('\nFibonacci Numbers: ');
|
||||
leoN(25, l0: 0, l1: 1, add: 0);
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
Const limit = 25
|
||||
|
||||
Sub leonardo(L0 As Integer, L1 As Integer, suma As Integer, texto As String)
|
||||
Dim As Integer i, tmp
|
||||
Print "Numeros de " &texto &" (" &L0 &"," &L1 &"," &suma &"):"
|
||||
|
|
@ -16,7 +18,7 @@ Sub leonardo(L0 As Integer, L1 As Integer, suma As Integer, texto As String)
|
|||
Print Chr(10)
|
||||
End Sub
|
||||
|
||||
'--- Programa Principal ---
|
||||
leonardo(1,1,1,"Leonardo")
|
||||
leonardo(0,1,0,"Fibonacci")
|
||||
End
|
||||
|
||||
Sleep
|
||||
|
|
|
|||
29
Task/Leonardo-numbers/Gambas/leonardo-numbers.gambas
Normal file
29
Task/Leonardo-numbers/Gambas/leonardo-numbers.gambas
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Public Const limit As Integer = 25
|
||||
|
||||
Public Sub Main()
|
||||
|
||||
leonardo(1, 1, 1, "Leonardo")
|
||||
leonardo(0, 1, 0, "Fibonacci")
|
||||
|
||||
End
|
||||
|
||||
Sub leonardo(L0 As Integer, L1 As Integer, suma As Integer, texto As String)
|
||||
|
||||
Dim i As Integer, tmp As Integer
|
||||
|
||||
Print "Numeros de " & texto & " (" & L0 & "," & L1 & "," & suma & "):"
|
||||
For i = 1 To limit
|
||||
If i = 1 Then
|
||||
Print " "; L0;
|
||||
Else If i = 2 Then
|
||||
Print " "; L1;
|
||||
Else
|
||||
Print " "; L0 + L1 + suma;
|
||||
tmp = L0
|
||||
L0 = L1
|
||||
L1 = tmp + L1 + suma
|
||||
End If
|
||||
Next
|
||||
Print Chr(10)
|
||||
|
||||
End Sub
|
||||
17
Task/Leonardo-numbers/MSX-Basic/leonardo-numbers.basic
Normal file
17
Task/Leonardo-numbers/MSX-Basic/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
100 LIMIT = 25
|
||||
110 L0 = 1
|
||||
120 L1 = 1
|
||||
130 SUMA = 1
|
||||
140 PRINT "Numeros de Leonardo (";L0;",";L1;",";SUMA;"):"
|
||||
150 GOSUB 220
|
||||
160 LET L0 = 0
|
||||
170 LET L1 = 1
|
||||
180 LET SUMA = 0
|
||||
190 PRINT "Numeros de Fibonacci (";L0;",";L1;",";SUMA;"):"
|
||||
200 GOSUB 220
|
||||
210 END
|
||||
220 FOR I = 1 TO LIMIT
|
||||
230 IF I = 1 THEN PRINT L0; : ELSE IF I = 2 THEN PRINT L1; : ELSE PRINT L0+L1+SUMA; : TMP = L0 : L0 = L1 : L1 = TMP+L1+SUMA
|
||||
240 NEXT I
|
||||
250 PRINT CHR$(10)
|
||||
260 RETURN
|
||||
11
Task/Leonardo-numbers/Minimal-BASIC/leonardo-numbers.basic
Normal file
11
Task/Leonardo-numbers/Minimal-BASIC/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
10 INPUT L0
|
||||
20 INPUT L1
|
||||
30 INPUT S
|
||||
40 PRINT L0;" ";L1;
|
||||
50 FOR I=3 TO 25
|
||||
60 LET T=L1
|
||||
70 LET L1=L0+L1+S
|
||||
80 LET L0=T
|
||||
90 PRINT " ";L1;
|
||||
100 NEXT I
|
||||
110 END
|
||||
25
Task/Leonardo-numbers/OxygenBasic/leonardo-numbers.basic
Normal file
25
Task/Leonardo-numbers/OxygenBasic/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
uses console
|
||||
|
||||
sub leonardo(L0 as integer, L1 as integer, suma as integer, texto as string)
|
||||
int i, tmp
|
||||
printl "Numeros de " texto " (" L0 "," L1 "," suma "):"
|
||||
for i = 1 to 25
|
||||
if i = 1 then
|
||||
print " " L0;
|
||||
elseif i = 2 then
|
||||
print " " L1;
|
||||
else
|
||||
print " " L0 + L1 + suma;
|
||||
tmp = L0
|
||||
L0 = L1
|
||||
L1 = tmp + L1 + suma
|
||||
end if
|
||||
next i
|
||||
printl cr
|
||||
end sub
|
||||
|
||||
leonardo(1,1,1,"Leonardo")
|
||||
leonardo(0,1,0,"Fibonacci")
|
||||
|
||||
printl cr "Enter ..."
|
||||
waitkey
|
||||
25
Task/Leonardo-numbers/QBasic/leonardo-numbers.basic
Normal file
25
Task/Leonardo-numbers/QBasic/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
DECLARE SUB leonardo (L0!, L1!, suma!, texto$)
|
||||
|
||||
CONST limit = 25
|
||||
CALL leonardo(1, 1, 1, "Leonardo")
|
||||
CALL leonardo(0, 1, 0, "Fibonacci")
|
||||
END
|
||||
|
||||
SUB leonardo (L0, L1, suma, texto$)
|
||||
PRINT "Numeros de "; texto$; " ("; L0; ","; L1; ","; suma; "):"
|
||||
FOR i = 1 TO limit
|
||||
IF i = 1 THEN
|
||||
PRINT L0;
|
||||
ELSE
|
||||
IF i = 2 THEN
|
||||
PRINT L1;
|
||||
ELSE
|
||||
PRINT L0 + L1 + suma;
|
||||
LET tmp = L0
|
||||
LET L0 = L1
|
||||
LET L1 = tmp + L1 + suma
|
||||
END IF
|
||||
END IF
|
||||
NEXT i
|
||||
PRINT CHR$(10)
|
||||
END SUB
|
||||
23
Task/Leonardo-numbers/True-BASIC/leonardo-numbers.basic
Normal file
23
Task/Leonardo-numbers/True-BASIC/leonardo-numbers.basic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
SUB leonardo (L0, L1, suma, texto$)
|
||||
PRINT "Numeros de "; texto$; " ("; L0; ","; L1; ","; suma; "):"
|
||||
FOR i = 1 TO limit
|
||||
IF i = 1 THEN
|
||||
PRINT L0;
|
||||
ELSE
|
||||
IF i = 2 THEN
|
||||
PRINT L1;
|
||||
ELSE
|
||||
PRINT L0 + L1 + suma;
|
||||
LET tmp = L0
|
||||
LET L0 = L1
|
||||
LET L1 = tmp + L1 + suma
|
||||
END IF
|
||||
END IF
|
||||
NEXT i
|
||||
PRINT CHR$(10)
|
||||
END SUB
|
||||
|
||||
LET limit = 25
|
||||
CALL leonardo(1, 1, 1, "Leonardo")
|
||||
CALL leonardo(0, 1, 0, "Fibonacci")
|
||||
END
|
||||
32
Task/Leonardo-numbers/Verilog/leonardo-numbers.v
Normal file
32
Task/Leonardo-numbers/Verilog/leonardo-numbers.v
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module leonardo #(parameter LIMIT = 25) (
|
||||
input [31:0] L0, L1, suma,
|
||||
input [8*8:1] texto
|
||||
);
|
||||
integer i;
|
||||
reg [31:0] tmp, l0, l1;
|
||||
initial begin
|
||||
l0 = L0;
|
||||
l1 = L1;
|
||||
$display("Numeros de %0s (%0d, %0d, %0d):", texto, L0, L1, suma);
|
||||
for (i = 1; i <= LIMIT; i = i + 1) begin
|
||||
if (i == 1)
|
||||
$write("%0d ", l0);
|
||||
else if (i == 2)
|
||||
$write("%0d ", l1);
|
||||
else begin
|
||||
$write("%0d ", l0 + l1 + suma);
|
||||
tmp = l0;
|
||||
l0 = l1;
|
||||
l1 = tmp + l1 + suma;
|
||||
end
|
||||
end
|
||||
$display("");
|
||||
end
|
||||
endmodule
|
||||
|
||||
module main;
|
||||
reg [8*8:1] texto1 = "Leonardo";
|
||||
reg [63:0] texto2 = "Fibonacci";
|
||||
leonardo #(25) leo1(1, 1, 1, texto1);
|
||||
leonardo #(25) fibo(0, 1, 0, texto2);
|
||||
endmodule
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
limit = 25
|
||||
leonardo(1,1,1,"Leonardo")
|
||||
leonardo(0,1,0,"Fibonacci")
|
||||
end
|
||||
|
||||
sub leonardo(L0, L1, suma, texto$)
|
||||
local i
|
||||
|
|
@ -15,7 +18,3 @@ sub leonardo(L0, L1, suma, texto$)
|
|||
next i
|
||||
print chr$(10)
|
||||
end sub
|
||||
|
||||
leonardo(1,1,1,"Leonardo")
|
||||
leonardo(0,1,0,"Fibonacci")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue