Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > La Taberna
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-06-2006
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Poder: 10
marcoszorrilla Va por buen camino
Para muestra un botón:

Código:
 Original Program

     /*
   Fermat Near-Miss Finder

   Written by David X. Cohen
   May 11, 1995.

   This program generated the equation:

   1782^12 + 1841^12 = 1922^12

   For "The Simpsons" episode "Treehouse Of Horror VI".
   Production code: 3F04
   Original Airdate: October 30, 1995
*/

#include <stdio.h>
#include <math.h>

main()
{
  double x, y, i, z, az, d, upmin, downmin;

  upmin = .00001;
  downmin = -upmin;

  for(x = 51.0; x <= 2554.0; x ++)
    {
      printf("[%.1f]", x);

      for(y = x + 1.0; y <= 2555.0; y ++)
        {
          for(i = 7.0; i <= 77.0; i ++)
            {
              z = pow(x, i) + pow(y, i);

              if(z == HUGE_VAL) {
                printf("[*]");
                break;  }

              z = pow(z, (1.0/i));

              az = floor(z + .5);
              d = z - az;

              if(az == y) break;

              if((d < 0.0) && (d >= downmin))
                {
                  downmin = d;

                  printf("\n%.1f, %.1f, %.1f, = %13.10f\n", x, y, i, z);
                }

              else if((d >= 0.0) && (d <= upmin))
                {
                  upmin = d;

                  printf("\n%.1f, %.1f, %.1f, = %13.10f\n", x, y, i, z);
                }

              if(z < (y + 1.0)) break;
            }
        }
    }

  return(1);
}

    Improved Program

     /*
   Fermat Near-Miss Finder

   Written by David X. Cohen
   February 3, 1998, 3:24 AM.
   
   This program generated the equation:

   3987^12 + 4365^12 = 4472^12

   For "The Simpsons" episode "The Wizard of Evergreen Terrace".
   Production code: 5F21
   Original Airdate: September 20, 1998
*/

#include <stdio.h>
#include <math.h>


#define EVEN(x)  ((((x) / 2.0) == floor((x) / 2.0)) ? 1 : 0)


main()
{
  double x, y, i, z, az, d, upmin;
  double bigboy;
  int evenx, eveny, evenz;
  
  upmin = .001;
  bigboy = 9.99 * pow(10.0, 99.0);

  for(x = 2990.0; x <= 4999.0; x ++)
    {
      printf("[%.0f]", x);

      evenx = EVEN(x);
      
      for(y = x + 1.0; y <= 5000.0; y ++)
        {
          eveny = EVEN(y);

          for(i = 7.0; i <= 77.0; i ++)
            {
              z = pow(x, i) + pow(y, i);

              if(z == HUGE_VAL) {
                printf("[*]");
                break;  }

              if(z > bigboy) break;

              z = pow(z, (1.0/i));
              az = floor(z + .5);
              d = z - az;

              if(az == y) break;

              if(d < 0.0) continue;

              evenz = EVEN(az);

              if(evenx == eveny)
                {
                  if(!evenz) continue;
                }
              else if(evenz) continue;

              if(d <= upmin)
                {
                  upmin = d;
                  
                  printf("\n%.1f, %.1f, %.1f, = %13.10f\n", x, y, i, z);
                }
              
              if(z < (y + 1.0)) break;
            }
        }
    }
  
  return(1);
}
Ya solo hubiese faltado que no fuera estadounidense.

Enlace.

Un Saludo.
__________________
Guía de Estilo de los Foros
Cita:
- Ça c'est la caisse. Le mouton que tu veux est dedans.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problemilla de matematicas. CRIS Varios 14 12-11-2005 12:25:27
FastReport: fórmula matemáticas. Jose_Pérez Impresión 1 01-09-2005 13:20:37
Matemáticas: Calcular porcentaje DarkByte Varios 9 01-02-2004 17:42:08
Expresiones matemáticas Pandre Varios 0 04-09-2003 01:43:49
expresion matematicas Irina Impresión 4 21-05-2003 00:49:51


La franja horaria es GMT +2. Ahora son las 08:17:26.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi