2
Inicio int n = 0; int a = 0; int b = 1; int s = 0; “hasta que número”, n a,b s = a + b; s <= n s a = b; b = s; Fin no si n a b s out 15 0 1 1 0 1 1 2 1 1 2 3 1 2 3 5 2 3 5 8 3 5 8 13 5 8 13 21 8 13

Algoritmos

Embed Size (px)

DESCRIPTION

Secuencia Fibonacci

Citation preview

Page 1: Algoritmos

Inicio

int n = 0; int a = 0;int b = 1; int s = 0;

“hasta que número”, n

a,b

s = a + b;

s <= ns

a = b;b = s;

Fin

no

si

n a b s out

15 0 1 1 0

1 1 2 1

1 2 3 1

2 3 5 2

3 5 8 3

5 8 13 5

8 13 21 8

13

Page 2: Algoritmos

Inicio

int c = 1; int ca = 0; int se = 0; int edad =; int pro = 0;

“# de alumnos”, ca

c <= ca

pro = se / ca

Fin

no

si“edad alumno”, edad

c = c + 1;se = se + edad;

“Promedio”,pro

El curso tiene 3 alumnos

ca c edad se pro out

0 1 0 0 0 28,3

3 2 25 25 28,3

3 30 55

4 30 85

c = contadorca = cantidad de alumnosse = suma de edadesprom = promedio edad = para pedir edad