elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [RETO] Determinar Número Perfecto
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] 3 Ir Abajo Respuesta Imprimir
Autor Tema: [RETO] Determinar Número Perfecto  (Leído 8,354 veces)
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #10 en: 23 Octubre 2013, 16:36 pm »

HOLA!!!

Me parece o alguien tomo de base mi ejemplo funcion... :silbar: :silbar: :silbar: :silbar: :silbar:

GRACIAS POR LEER!!!

jajaja sí, yo a las funciones las llamo asd o sdav jajaja


En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
79137913


Desconectado Desconectado

Mensajes: 1.169


4 Esquinas


Ver Perfil WWW
Re: [RETO] Determinar Número Perfecto
« Respuesta #11 en: 23 Octubre 2013, 16:47 pm »

HOLA!!!

Hice una pequeña prueba  con el maximo numero que soporta tu funcion y solo una llamada:


For the record:
Mi funcion recien empieza a tener un tiempo registrable luego de las 1000 llamadas (4ms) con 10000 llamadas llega a 47ms!
 
Y por supuesto...
Con el numero: 2305843008139952128

@Miseryk :
En vez de buscar el ultimo digito de esa manera buscalo asi, ya que tu funcion no acepta numeros mayor que long te va a servir:
Código
  1. Lastnum = Numero mod 10

GRACIAS POR LEER!!!


« Última modificación: 23 Octubre 2013, 16:52 pm por 79137913 » En línea

"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

 79137913                          *Shadow Scouts Team*
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #12 en: 23 Octubre 2013, 16:57 pm »

Código Completo:

Código
  1. Option Explicit
  2.  
  3. '6
  4. '28
  5. '496
  6. '8128
  7. '33550336
  8. '8589869056
  9. '137438691328
  10. '2305843008139952128
  11.  
  12. Public Function Misery_MOD(ByVal dividendo As Double, ByVal divisor As Double) As Double
  13. 'x / y = z
  14. 'y * z + R = x
  15.  
  16. '10 / 3 = 3,333
  17. '10 / 3 = 3
  18. Misery_MOD = dividendo - (divisor * Fix(dividendo / divisor))
  19. End Function
  20.  
  21. Public Function IsPerfect(ByRef numero As Double) As Boolean
  22. Dim loopc As Double
  23. Dim calc As Double
  24.  
  25. Dim LastNum As Byte
  26.  
  27. Dim Max As Variant
  28.  
  29. Max = Fix(CDbl(numero) / CDbl(2))
  30.  
  31. 'By 79137913
  32. LastNum = numero Mod 10
  33.  
  34. If LastNum = 6 Or LastNum = 8 Then
  35.    For loopc = Max To 1 Step -1
  36.        'If numero Mod loopc = 0 Then
  37.        If Misery_MOD(numero, loopc) = 0 Then
  38.            calc = calc + loopc
  39.  
  40.            If calc > numero Then
  41.                IsPerfect = False
  42.                Exit Function
  43.            End If
  44.        End If
  45.    Next loopc
  46. End If
  47.  
  48. IsPerfect = (calc = numero)
  49. End Function
  50.  
  51. Private Sub Form_Load()
  52. 'MsgBox 33550336 Mod 10
  53. MsgBox IsPerfect(33550336)
  54. End
  55. End Sub
  56.  

Modificación_2
« Última modificación: 23 Octubre 2013, 17:05 pm por Miseryk » En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #13 en: 23 Octubre 2013, 16:58 pm »

HOLA!!!

Hice una pequeña prueba  con el maximo numero que soporta tu funcion y solo una llamada:


For the record:
Mi funcion recien empieza a tener un tiempo registrable luego de las 1000 llamadas (4ms) con 10000 llamadas llega a 47ms!
 
Y por supuesto...
Con el numero: 2305843008139952128

@Miseryk :
En vez de buscar el ultimo digito de esa manera buscalo asi, ya que tu funcion no acepta numeros mayor que long te va a servir:
Código
  1. Lastnum = Numero mod 10

GRACIAS POR LEER!!!

Wow, interesante, no se me había ocurrido.
En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #14 en: 23 Octubre 2013, 17:29 pm »

Estuve probando ésto en .NET que soporta números muy grandes, y la función que hiciste en números muy grandes retorna True en todos los números, estoy pasándolo a VB.NET para que lo veas mejor.
En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
79137913


Desconectado Desconectado

Mensajes: 1.169


4 Esquinas


Ver Perfil WWW
Re: [RETO] Determinar Número Perfecto
« Respuesta #15 en: 23 Octubre 2013, 17:38 pm »

HOLA!!!

Esto es VB6!!!!!!!! (con el tono de "ESTO ES ESPARTAAAAAA")

Que el No-Compilador de Net sea idiota no es mi problema.-

GRACIAS POR LEER!!!
En línea

"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

 79137913                          *Shadow Scouts Team*
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #16 en: 23 Octubre 2013, 18:14 pm »

Nono, es cierto, me faltó una conversión de tu función a UInt64, el código funciona bien y muy rápido :D :D
En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #17 en: 23 Octubre 2013, 19:19 pm »

Voy a esperar a ver quién más postea algún código mientras mejoro el mio.

Estoy en .NET (solamente por el número que uso para testear la función) utilizando como prueba el número perfecto 2305843008139952128

Con respecto a los resultados en y con:
SO: Windows 7 Ultimate 64 bits
Procesador: Intel(R) Core(TM) i5-3570K CPU @ 3.40Ghz 3.40GHz
Memoria instalada (RAM): 16,0 GB

79137913:
Número: 2305843008139952128
Resultado: True
Tiempo Milisegs: 0,0084 (EL MÍNIMO TIEMPO POSIBLE DE DEMASIADOS INTENTOS)




PD: el mio no lo muestro porque necesito una computadora quántica para que me diga el tiempo que tarda, pero estoy en éso.
« Última modificación: 23 Octubre 2013, 19:52 pm por Miseryk » En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
Miseryk

Desconectado Desconectado

Mensajes: 225


SI.NU.SA U.GU.DE (2NE1 - D-Unit)


Ver Perfil
Re: [RETO] Determinar Número Perfecto
« Respuesta #18 en: 25 Octubre 2013, 18:23 pm »

HOLA!!!

Mi funcion puede verificar los numeros perfectos sin problema, probe con el ultimo que esta aca y lo verifica en menos de 0,1 ms .-

Para que vean que lo que importa es el algoritmo no el lenguaje ;)

Código
  1. Private Function IsPerfect(N As Double) As Boolean
  2.    Dim Sum As Double
  3.    Dim Aux As Double
  4.    Aux = N / 2
  5.    Sum = 1 + Aux
  6.    Do While Aux > 2
  7.        If Fix(Aux / 2) < Aux / 2 Then
  8.            Aux = Aux + 1
  9.        End If
  10.        Aux = Aux / 2
  11.        Sum = Sum + Aux
  12.    Loop
  13.    IsPerfect = (N = Sum)
  14. End Function

Superenme ;)

GRACIAS POR LEER!!!

Mientras estuve tratando de crear un algoritmo, me dí cuenta que esa función retorna mal algunos valores como por ejemplo:

al verificar con el número 2 retorna Verdadero el cual no es perfecto.
al verificar con el número 12 retorna Verdadero el cual no es perfecto.
al verificar con el número 14 retorna Verdadero el cual no es perfecto.
al verificar con el número 24 retorna Verdadero el cual no es perfecto.
etc
En línea

Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It’s never too late to change our luck
So, don’t let them steal your light
Don’t let them break your stride
There is light on the other side
And you’ll see all the raindrops falling behind
Make it out tonight
it’s a revolution

CL!!!
79137913


Desconectado Desconectado

Mensajes: 1.169


4 Esquinas


Ver Perfil WWW
Re: [RETO] Determinar Número Perfecto
« Respuesta #19 en: 26 Octubre 2013, 04:57 am »

HOLA!!!

:O

Lo soluciono el lunes!

GRACIAS POR LEER!!!
En línea

"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

 79137913                          *Shadow Scouts Team*
Páginas: 1 [2] 3 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines