*JOHANNA AGUILAR
*JOSE BAÑO
*SAYRI MENDOZA
*JAIME PAREDES
#probar hasta la raíz cuadrada del número para ver si es divisible por algún otro número.
primo <- function(){
num4<-as.integer(dlgInput(message="POR FAVOR, INGRESE UN NÚMERO ")$res)
if(sum(num4/1:num4==num4%/%1:num4)==2){
(m <- paste0("EL NUMERO: ", num4 , " ES PRIMO "))
}else{(m <- paste0("EL NÚMERO: ", num4, " NO ES PRIMO"))}
}
primo()
ahorros<-function(a)
{
print("DEPOSITO ANUAL")
MESES<-c("ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO",
"SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE")
for(i in MESES)
DEPOSITOS_M<- as.numeric(dlgInput(message="POR FAVOR, INGRESE LA CANTIDAD A AHORRAR:")$res)
DATOS<-data.frame(MESES,DEPOSITOS_M)
print(DATOS)
cat("TOTAL DEL DEPOSITO ANUAL : ",sum(DEPOSITOS_M))
}
depositosA<-ahorros(a)
horas<- 0
total_horas<- 0
dias<- c("LUNES", "MARTES", "MIERCOLES", "JUEVES", "VIERNES", "SABADO")
for(i in dias)
{
horas<- as.numeric(readline("¿CUANTAS HORAS TRABAJO?"))
total_horas<- total_horas+ horas
sueldo<- total_horas*2.50
print(paste("EL", i, "TRABAJO", horas, "HORAS"))
}
int(paste("EL SUELDO QUE RECIBIRA ES DE: $", sueldo))
p1<- 70
p2<- 150
km<- 0
while(p1 == p2)
{
persona1<- p1+1
persona2<- p2-1
km<- persona2-persona1
}
print(paste("SE ENCONTRARON EN EL KILOMETRO", km))
pago<- 10
total<- 0
for(i in 1:20)
{
pago<- pago*2
total<- total + pago
print(paste("EN EL MES", i, "PAGARAS: $", pago))
}
## [1] "EN EL MES 1 PAGARAS: $ 20"
## [1] "EN EL MES 2 PAGARAS: $ 40"
## [1] "EN EL MES 3 PAGARAS: $ 80"
## [1] "EN EL MES 4 PAGARAS: $ 160"
## [1] "EN EL MES 5 PAGARAS: $ 320"
## [1] "EN EL MES 6 PAGARAS: $ 640"
## [1] "EN EL MES 7 PAGARAS: $ 1280"
## [1] "EN EL MES 8 PAGARAS: $ 2560"
## [1] "EN EL MES 9 PAGARAS: $ 5120"
## [1] "EN EL MES 10 PAGARAS: $ 10240"
## [1] "EN EL MES 11 PAGARAS: $ 20480"
## [1] "EN EL MES 12 PAGARAS: $ 40960"
## [1] "EN EL MES 13 PAGARAS: $ 81920"
## [1] "EN EL MES 14 PAGARAS: $ 163840"
## [1] "EN EL MES 15 PAGARAS: $ 327680"
## [1] "EN EL MES 16 PAGARAS: $ 655360"
## [1] "EN EL MES 17 PAGARAS: $ 1310720"
## [1] "EN EL MES 18 PAGARAS: $ 2621440"
## [1] "EN EL MES 19 PAGARAS: $ 5242880"
## [1] "EN EL MES 20 PAGARAS: $ 10485760"
print(paste("EL TOTAL QUE PAGASTE EN 20 MESES ES DE: $", total))
## [1] "EL TOTAL QUE PAGASTE EN 20 MESES ES DE: $ 20971500"
empresa<-function(num){
empleados<- as.numeric(dlgInput(message="CUANTOS TRABAJADORES TIENE?")$res)
gasto_empresa<- 0
for(num in 1:empleados){
horas<-as.numeric(dlgInput(message="CUANTAS HORAS TRABAJO A LA SEMANA?")$res)
gasto_empresa<- gasto_empresa + horas*2.50
sueldo<- horas*2.50
print(paste("EL EMPLEADO", num, "GANA SEMANAL: $", sueldo))
}
print(paste("LA EMPRESA PAGO POR LOS", empleados, "EMPLEADOS", gasto_empresa))
}
empresa()
empresa2<-function(num){
trab<- as.numeric(dlgInput(message="CUANTOS EMPLEADOS TIENE?")$res)
pago<- 0
for(num in 1:trab){
dias<- as.numeric(dlgInput(message="CUANTOS DIAS TRABAJO EN LA SEMANA?")$res)
horas<- as.numeric(dlgInput(message="CUANTOS HORAS TRABAJO EN ESOS DIAS?")$res)
sueldo<- (dias*horas)*2.50
pago<- pago+ (dias*horas)+ sueldo
print(paste("EL EMPLEADO", num, "GANA SEMANAL: $", sueldo))
}
print(paste("LA EMPRESA PAGA SEMANALMENTE POR LOS", trab, "EMPLEADOS: $", pago))
}
empresa2()
cronometro<- function(seg)
{
print(seg)
while(seg!=0)
{
Sys.sleep(1)
seg<- seg-1
print(seg)
}
}
cronometro(seg<-as.numeric(dlgInput(message="INGRESE UN NUMERO:")$res))
menu<-function(){
opc1<-as.numeric(dlgInput(message="MENU PRINCIPAL
OPCION 1
OPCION 2
OPCION 3
OPCION 4
SALIR 5
***SELECCIONE UNA OPCION:***")$res)
if(opc1==1){
opc1 <- dlgInput(message="OPCION 1:
1.- REGRESAR AL MENU
2.- SALIR
***SELECCIONE UNA OPCION:***")$res
opc1<-as.character(opc1)
if(opc1==1){menu()}
}else if(opc1==2){
opc1 <- dlgInput(message="OPCION 2:
1.- REGRESAR AL MENU
2.- SALIR
***SELECCIONE UNA OPCION:***")$res
opc1<-as.numeric(opc1)
if(opc1==1){menu()}
}else if(opc1==3){
opc1 <- as.numeric(dlgInput(message="OPCION 3:
1.- REGRESAR AL MENU
2.- SALIR
***SELECCIONE UNA OPCION:***")$res)
if(opc1==1){menu()}
}else if(opc1==4){
opc1 <- as.numeric(dlgInput(message="OPCION 4:
1.- REGRESAR AL MENU
2.- SALIR
***SELECCIONE UNA OPCION:***")$res)
if(opc1==1){menu()}
}
}
menu()
numpri<- function(num)
{
primo<-numeric()
no_primo<-numeric()
for (i in 1:num)
{
if (sum(i/1:i==i%/%1:i)==2)
{
no_primo<-c(no_primo,i)
} else
{
primo<-c(primo,i)
}
}
primo
no_primo
}
numpri(10)
## [1] 2 3 5 7