Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mathematics knundrum
Message
De
26/04/2003 13:42:08
 
 
À
26/04/2003 12:40:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00780672
Message ID:
00781845
Vues:
39
>I think there's a large prize awaiting anyone who can prove a number prime without using brute force (perhaps more precisely, to create a formula which will unfailingly generate primes), which, I'm afraid, that algorithm is only capable of.
>
>So, maybe there's a practical benefit to theoretical math after all!
>
>
> Jay

hi Jay

i am not that verse in Math, and i proppably missunderstood you, but is this what you're looking for (there is a website with primenumbers at http://www.utm.edu/research/primes/lists/small/1000.txt): -)
CLEAR

* *** main loop
FOR i=1 TO 4060
   IF IsPrime(i) = .T.
      ?i
   ENDIF
ENDFOR

RETURN

* *** *******************************************************
FUNC IsPrime(Num2Check)
   LOCAL ;
      xi, ;
      TargetLoop, ;
      ReturnValue

   ReturnValue = .T.
   TargetLoop = ROUND(Num2Check/2, 0)
   FOR xi=2 TO TargetLoop
      IF MOD(Num2Check, xi) = 0
         ReturnValue = .F.
         EXIT
      ENDIF
   ENDFOR
   RETURN(ReturnValue)
ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform