Está en la página 1de 20

UNIVERSIDAD AUTÓNOMA GABRIEL RENE MORENO FACULTAD DE

INGENIERÍA Y CIENCIAS DE LA COMPUTACIÓN Y TELECOMUNICACIONES

PROGRAMACION I
COMENTARIOS:
El laboratorio presente es bastante complicado y con mucha lógica que nos costó
pensar y lograr resolver los problemas con la ayuda también de otros grupos y
amigos y al final logramos acabar el laboratorio con los resultados positivo y
verdaderos que nos pide cada problema en Visual Basic tuvimos problemas al hora
de implementarlo con “SUB” como procedimiento como fue la primera vez lo usábamos
de esa manera y en Python no hubo mucho problema ya que todo era más lógica y una
pequeña observación para ayudarnos a hacer el practico sería poner algunos
ejemplos de números en los problemas para ver si exactamente están bien como nos
pide lo problemas y así verificarlo, en Java no hubo mucho problema también.
Aprendimos una lógica más en esta materia de programación 1
PORCENTAJE TERMINADO: 100%.

GRUPO: 14

Integrantes DT HG HI EVAL
Carlos Enrique Maldonado Cuellar 2 1 0 100%
Lanza Davalos Alison Gabriela 0 0 0 0%

Magne Yampara Erwin Brayan 2 1 0 100%


Mamani Apaza Zenaida 2 1 0 100%
Limachi Villa Milan Ariel 2 1 0 100%
.

Fecha de Presentación: miércoles, 27 de marzo del 2019


Fecha Presentada: miércoles, 27 de marzo del 2019

Días de Retraso: 0

PYTHON:

def mostrarDivasc(n):
i=1

while i<=n:

if n%i==0:

print(i)

i=i+1

def mostrarDivde(n):

i=n

while i>0:

if n%i==0:

print(i)

i=i-1

def mostrarDivPares(n):

i=1

while i<=n:

if (n%i==0) and (i%2==0):

print (i)

i=i+1

def mostrarDivImpares(n):

i=1

while i<=n:

if (n%i==0) and (i%2==1):

print (i)

i=i+1

def divisoresComunes(n,m):

i=1

while i<=n and i<=m:

if n% i==0 and m % i==0:


print (i)

i=i+1

def mostrarDivisores(n,a,b):

i=a

while i<=b:

if n%i==0:

print(i)

i=i+1

def proximoDiv(n,a):

i=a+1

while i<=n:

if n%i==0:

print(i)

i=i+1

def anteriosDiv(n,a):

i=a-1

while i>=1:

if n%i==0:

print(i)

i=i-1

def primo1(n):

i=2

while i<=n/2:

if(n%i==0):

return False

i=i+1

return True

def primo2(n):
i=1 c=0

while i<=n:

if n%i==0:

c=c+1 i=i+1

return c==2

def mostrarPrimos(a,b):

i=a

while i<=b:

if (primo2(i)==True):

print(i)

i=i+1

def cantPrimos(n):

i=1 c=1

while i<=n:

if (primo2(i)==True):

c=c+1 i=i+1

return c

def cantidadPrimos(a,b):

i=a c=0

while i<=b:

if primo(i):

c=c+1

i=i+1

return c

def mostrarDivPrimos(n):

i=1

while i<=n:
if n%i==0 and primo2(i):

print(i)

i=i+1

VISUAL BASIC:

Module Module1

Sub mostrarDiv(n As Integer)

Dim i = 1

While (i <= n)

If (n Mod i = 0) Then
Console.WriteLine(i)

i = i + 1

End While

End Sub

Sub mostrarDivisoresDesc(n As
Integer)

Dim i = 1

While (i >= n)

If (n Mod i = 0) Then
Console.WriteLine(i)

i = i + 1

End While

End Sub

Sub mostrarDivisoresPares(N As
Integer)

Dim i = 1

While (i <= N)

If (N Mod i = 0 And i Mod


2 = 0) Then Console.WriteLine(i)
i = i + 1

End While
End Sub

Sub mostrarDivisoresImpares(N As
Integer)

Dim i As Integer = 1

While (i <= N)

If (N Mod i = 0 And i Mod


2 = 1) Then Console.WriteLine(i)
i = i + 1

End While

End Sub

Sub mostrarDivAB(n As Integer, m


As Integer)

Dim i = n

While (i > 0)

If (n Mod i = 0 And m Mod


i = 0) Then Console.WriteLine(i)
i = i - 1

End While

End Sub

Function suumaDiv(n As Integer)


As Integer

Dim i = 1

Dim sum = 0

While (i <= n)

If (n Mod i = 0) Then sum


= sum + i

i = i + 1

End While
Return sum

End Function

Function cantidadDiv(n As
Integer) As Integer

Dim i = 1

Dim c = 0

While (i <= n)

If (n Mod i = 0) Then c =
c + 1 i = i + 1
End While

Return c

End Function

Function ProximoDiv(n As Integer,


a As Integer) As Integer

Dim i = a + 1

While (n Mod i <> 0)

i = i + 1

End While

Return i

End Function

Function AnteriorDiv(n As
Integer, a As Integer) As Integer

Dim i = a - 1 While
(n Mod i <> 0)

i = i - 1

End While

Return i

End Function

Function productoDiv(n As
Integer) As Integer

Dim i = 1, p = 1
While (i <= n)

If (n Mod i = 0) Then p =
p * i

i = i + 1 End
While

Return p

End Function

Function Primo01(n As Integer) As


Boolean

Return cantidadDiv(n) = 2

End Function

Function Primo02(n As Integer) As


Boolean

Dim i = 2

While (i <= n / 2)

If (n Mod i = 0) Then
Return False

i = i + 1

End While

Return True

End Function

Sub MostrarDivPrimo(n As Integer)

Dim i = 1

While (i <= n)

If (n Mod i = 0 And
Primo02(i)) Then Console.WriteLine(i)
i = i + 1 End While

End Sub

Sub MostrarPrimos(a As Integer, b


As Integer)

Dim i = a

While (i <= b)
If (Primo02(i) = True)
Then WriteLine(i)

i = i + 1

End While

End Sub

Function SumaDivPrimos(n As
Integer) As Integer

Dim i = 1

Dim sum = 0

While (i <= n)

If (n Mod i = 0 And
Primo02(i)) Then sum = sum + i
i = i + 1 End While

Return sum

End Function

Function IesimoPrim(n As Integer)


As Integer

Dim i = 0

Dim c = 1 While (c <=


n)

i = i + 1

If (Primo02(i) = True)
Then c = c + 1

End While

Return i

End Function

Function CantidadPrimo(a As
Integer, b As Integer) As Integer

Dim i = a

Dim c = 0

While (i <= b)
If (Primo02(i)) Then c =
c + 1

i = i + 1

End While

Return c

End Function

Function NextPrimo(n As Integer)


As Integer

Dim i = n

While (Not Primo02(i))

i = i + 1

End While

Return i

End Function

Function AnteriorPrimo(n As
Integer) As Integer

Dim i = n

While (Not Primo02(i))

i = i - 1

End While

Return i

End Function

Function CantDivPrimo(n As
Integer) As Integer

Dim i = 1, c = 0

While (i <= n)

If (n Mod i = 0 And
Primo02(i)) Then c = c + 1
i = i + 1 End While

Return c

End Function
Function DosPrimos(a As Integer,
b As Integer, c As Integer) As
Boolean Return Primo02(a)
And Primo02(b) And Not Primo02(c) Or

Primo02(a) And Primo02(c) And


Not Primo02(b) Or

Primo02(b) And Primo02(c) And


Not Primo02(a)

End Function

Function primo(ByVal n As
Integer) As Boolean

Dim i = 2

While i <= n / 2

If n Mod i = 0 Then
Return False

i = i + 1

End While

Return True

End Function

Function primo(ByVal n As
Integer) As Boolean

Dim i = 2, lim = n / 2

While i <= lim

If n Mod i = 0 Then
Return False i = i + 1

End While

Return True

End Function

Function iesimoPrimo(ByVal n As
Integer) As Integer
Dim i = 0, j = 1

While Not primo(i) Or j <= n


If primo(i) Then j = j + 1

i = i + 1 End
While

Return i

End Function

Function cantidadPrimos(ByVal a
As Integer, ByVal b As Integer) As
Integer

Dim i = a, j = 0

While i <= b

If primo(i) Then j = j +
1 i = i + 1

End While

Return j

End Function

Function siguientePrimo(ByVal n
As Integer) As Integer

Dim i = n + 1

While Not primo(i)

i = i + 1

End While

Return i

End Function

Function anterioPrimo(ByVal n As
Integer) As Integer

Dim i = n - 1

While Not primo(i)

i = i - 1

End While
Return i

End Function

Sub cantidadDeVueltas(ByVal n As
Integer)

Dim i = 2, lim = n / 2

While i <= lim primo(i)


i = i + 1

End While

Console.WriteLine(i)

End Sub

Function cantidadDeVueltas2(ByVal
n As Integer) As Integer

Dim i = 1, j = 0
While i <= n

j = j + 1 End

While

Return j

End Function

Function cantidadDIVPrimos(ByVal
n As Integer) As Integer

Dim i = 1, j = 0

While i <= n

If primo(i) And (n Mod i


= 0) Then j = j + 1 i = i
+ 1 End While

End Function

Function DosPrimo(ByVal a As
Integer, ByVal b As Integer, ByVal c
As Integer) As Boolean If
(Not primo(a) And primo(b) And
primo(c)) Then

Return True
Else

If (primo(a) And Not


primo(b) And primo(c)) Then

Return True

Else

If (primo(a) And
primo(b) And Not primo(c)) Then

Return True

End If

End If

End If

Return False

End Function

Function DosPrimo(ByVal a As
Integer, ByVal b As Integer, ByVal c
As Integer, ByVal d As Integer) As
Boolean

If (Not primo(a) And primo(b)


And primo(c) And primo(d)) Then
Return True

Else

If (primo(a) And Not


primo(b) And primo(c) And primo(d))
Then

Return True

Else

If (primo(a) And
primo(b) And Not primo(c) And
primo(d)) Then

Return True

Else
If (primo(a) And
primo(b) And primo(c) And Not
primo(d)) Then

Return True

End If

End If

End If

End If

Return False

End Function

End Sub

End Module
JAVA:

public static void divisoreAsc(int


n)

{ int i = 1;
while (i<=n)

if (n%i==0)
System.out.println(i);

i=i+1;

public static void


divisoresDes(int n)

{ int i=n; while(i>0)

if(n%i==0 )
System.out.println(i);

i=i-1;

public static void


mostrardivipares(int n) {

int i=1;

while (i<=n)

if ((n%i==0) && (i%2==0))


System.out.println(i);

i=i+1;

}
}

public static void


mostrardiviimpares(int n) {

int i=1; while (i<=n)

if ((n%i==0) && (i%2==1))


System.out.println(i);

i=i+1;

public static int


cantDivisores(int n)

int i=1, c=0;

while(i<=n)

if(n%i==0) c=c+1;

i=i+1;

return c;

public static void


divisoreComunes(int n, int m)

int i = 1;

while ((i<=n) && (i<=m))

if ((n%i==0) && (m%i==0))


System.out.println(i);
i=i+1;

//// PRIMOS Y DIVISORES PRIMOS


public

static boolean primo1(int n)

return cantDivisores(n)==2;

public static boolean primo2(int n)

{ int i=2; while (i<=n/2)

if (n% i==0) return false; i=i+1;

return true;

public static void


mostrarDivPrimo(int n)

{ int i=1;

while(i<=n)

if((n%i==0) && primo1(i))


System.out.println(i);

i=i+1;

public static void mostrarPrimos(int


a , int b)

{ int i=a; while (i<=b)

{
if
(primo1(i)==true)System.out.println(i
);

i=i+1;

public static int sumaDivPrimos(int


n)

{ int i=1; int sum=0;

while (i<=n)

if ( n%i==0 && primo1(i)) sum


=sum +i;

i =i+1;

return sum;

public static int iesimoPrimo(int n)

{ int i=0; int c=1; while (c<=n)

i=i+1; if

(primo1(i)==true)c=c+1;

return i;

public static int cantidadPrimos(int


a , int b)

int c=0; int i=a;

while (i<=b)

{
if (primo1(i))c=c+1;

i=i+1;

return c;

public static int siguienPrimo (int n){

int i=n; while (!primo2(i)){


i=i+1;

return i;

public static int antePrimo (int n){

int i=n; while

(!primo2(i)){ i=i-1;

return i;

public static int cantDivPrimo (int n ){

int i=1, c=0; while(i<=n){


if

(n%i==0 && primo2 (i)) c=c+1;

i=i+1;

return c;

public static boolean dosPrimos (int a,


int b, int c){

return primo2(a) && primo2 (b) && !primo2


(c)|| primo2(a)

&& primo2 (c) && !primo2 (b)||

primo2(b) && primo2 (c) && !primo2 (a);

También podría gustarte