Edición de «Práctica 3: Cuantificadores (Algoritmos I)»
De Cuba-Wiki
Puedes deshacer la edición. Antes de deshacer la edición, comprueba la siguiente comparación para verificar que realmente es lo que quieres hacer, y entonces publica los cambios para así efectuar la reversión.
Revisión actual | Tu texto | ||
Línea 7: | Línea 7: | ||
# (<math>\forall j \in [0..|s|)) s_j == x </math> | # (<math>\forall j \in [0..|s|)) s_j == x </math> | ||
# (<math>\exists x \in r, x\ mod\ 2 == 0)(\forall j \in [0..|s|)) s_j == x </math> | # (<math>\exists x \in r, x\ mod\ 2 == 0)(\forall j \in [0..|s|)) s_j == x </math> | ||
# <math> ( |s|>5 \land a < b-1 \land (\forall j \in [a..b)) 2 * s_j == s_{j+1})</math> | # <math> ( |s|>5 \land a<b-1 \land (\forall j \in [a..b)) 2 * s_j == s_{j+1})</math> | ||
Línea 46: | Línea 46: | ||
'''Respuestas:''' | '''Respuestas:''' | ||
a) aux suc <math>(x: \mathbb{Z}): \mathbb{Z}</math> = x + 1 | a) aux suc <math>(x: \mathbb{Z}): \mathbb{Z}</math> = x+1 | ||
b) aux suma <math>(x,y: \mathbb{R}): \mathbb{R}</math> = x + y | b) aux suma <math>(x,y: \mathbb{R}): \mathbb{R}</math> = x + y | ||
c) aux producto<math>(x, y: \mathbb{R}): \mathbb{R}</math> = x * y | c) aux producto<math>(x, y: \mathbb{R}): \mathbb{R}</math> = x * y | ||
d) aux cuadrado<math>(x: \mathbb{Z})</math>: Bool = | d) aux cuadrado<math>(x: \mathbb{Z})</math>: Bool = (<math>\exists y \leftarrow</math> [1..y]) y*y = x | ||
e)aux primo<math>(x: \mathbb{Z})</math>: Bool = |[ y | y <math>\leftarrow</math>[1..|x|], x mod y == 0]| == 2 (Recordemos que un número es primo si tiene exactamente dos divisores positivos: el 1 y su valor absoluto) | e)aux primo<math>(x: \mathbb{Z})</math>: Bool = |[ y | y <math>\leftarrow</math>[1..|x|], x mod y == 0]| == 2 (Recordemos que un número es primo si tiene exactamente dos divisores positivos: el 1 y su valor absoluto) | ||
f) aux coprimos<math>(x,y: \mathbb{Z})</math>: Bool == |[ z | z <math>\leftarrow</math> [ | f) aux coprimos<math>(x,y: \mathbb{Z})</math>: Bool == |[ z | z <math>\leftarrow</math> [0..x], x mod z==0, y mod z == 0]| == 1 (Dos números son coprimos si tienen un único divisor positivo en común: el uno) | ||
g) aux divisoresGrandes<math>(x,y : \mathbb{Z})</math>: Bool = (<math>\forall</math> z <math>\leftarrow</math> [ t | t <math>\leftarrow</math> [2..|x|], x mod t == 0]) z > y | g) aux divisoresGrandes<math>(x,y : \mathbb{Z})</math>: Bool = (<math>\forall</math> z <math>\leftarrow</math> [ t | t <math>\leftarrow</math> [2..|x|], x mod t == 0]) z > y | ||
Línea 62: | Línea 62: | ||
h) aux mayorPrimo<math>(x: \mathbb{Z}): \mathbb{Z}</math> = | h) aux mayorPrimo<math>(x: \mathbb{Z}): \mathbb{Z}</math> = | ||
<math>[y | y \leftarrow [0..|x|], primo(y), x \ mod \ y == 0 ]_{|[ y | y \leftarrow [0..|x|], \ primo(y), x \ mod \ y == 0]|-1}</math> | <math>[y | y \leftarrow [0..|x|], primo(y), x \ mod \ y == 0 ]_{|[ y | y \leftarrow [0..|x|], \ primo(y), x \ mod \ y == 0]|-1}</math> | ||
i) aux mcm<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = cab([ z | z <math>\leftarrow</math> [0..|x*y|], z \ mod \ x == 0, z \ mod \ y == 0]) | i) aux mcm<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = cab([ z | z <math>\leftarrow</math> [0..|x*y|], z \ mod \ x == 0, z \ mod \ y == 0]) | ||
j) aux mcd<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = <math>[ z | z \leftarrow [0..|x|], x \ mod \ z == 0, y \ mod \ z == 0 ]_{[ z | z \leftarrow [0..|x|], x \ mod \ z == 0, y \ mod \ z == 0 ] - 1}</math> | j) aux mcd<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = <math>[ z | z \leftarrow [0..|x|], x \ mod \ z == 0, y \ mod \ z == 0 ]_{[ z | z \leftarrow [0..|x|], x \ mod \ z == 0, y \ mod \ z == 0 ] - 1}</math> | ||
===Ejercicio 3=== | ===Ejercicio 3=== | ||
Línea 74: | Línea 73: | ||
1. ''capicua'', que determina si una secuencia es capicúa. (Por ejemplo, [0,2,1,2,0] es capicúa y [0,2,1,4,0] no). | 1. ''capicua'', que determina si una secuencia es capicúa. (Por ejemplo, [0,2,1,2,0] es capicúa y [0,2,1,4,0] no). | ||
''capicua''(x: [T]): Bool = (<math>\forall</math>i <math> \leftarrow</math> [0..|x| | ''capicua''(x: [T]): Bool = (<math>\forall</math>i <math> \leftarrow</math> [0..|x|/2]) <math>x_{i-1}==x_{|x|-i}</math> | ||
Línea 80: | Línea 79: | ||
''esPrefijo''(x,y: [T]): Bool = (<math>\exists</math> i <math>\leftarrow</math> [0..|y|-1]) x==[<math>y_i</math>| j <math>\leftarrow</math> [0..i] ] | ''esPrefijo''(x,y: [T]): Bool = (<math>\exists</math> i <math>\leftarrow</math> [0..|y|-1]) x==[<math>y_i</math>| j <math>\leftarrow</math> [0..i] ] | ||
3. ''estaOrdenada'', que determina si la secuencia está ordenada de menor a mayor. | 3. ''estaOrdenada'', que determina si la secuencia está ordenada de menor a mayor. | ||
Línea 119: | Línea 114: | ||
''sinRepetidos''(x: [T]): Bool = (<math>\forall</math> i,j <math>\leftarrow</math> [0..|x|-1], i <math>\neq</math>j) <math>x_i \neq x_j </math> | ''sinRepetidos''(x: [T]): Bool = (<math>\forall</math> i,j <math>\leftarrow</math> [0..|x|-1], i <math>\neq</math>j) <math>x_i \neq x_j </math> | ||
Línea 150: | Línea 141: | ||
''enTresPartesPrima''(x: [<math>\mathbb{Z}]</math>): Bool = ( estaOrdenada(x) <math> \land (\forall</math> a <math>\leftarrow</math> x) <math> (0 \geq a \ \land \ a \leq 2 </math> ) ) | ''enTresPartesPrima''(x: [<math>\mathbb{Z}]</math>): Bool = ( estaOrdenada(x) <math> \land (\forall</math> a <math>\leftarrow</math> x) <math> (0 \geq a \ \land \ a \leq 2 </math> ) ) | ||
===Ejercicio 4=== | ===Ejercicio 4=== | ||