Ooops
October 17, 2021, 09:52:53

Author Topic: [bmx] special prime numbers by Vignoli [ 1+ years ago ]  (Read 591 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : special prime numbers
Author : Vignoli
Posted : 1+ years ago

Description : Enter a multiple of 6 in the program, and the program will evaluate the first prime number after the number you entered, by trying to add little prime numbers to it.
This program can be powerfull with : blitzmax + linux + (a supercalculator or a cluster) + an adaptation of the source code to find very very big prime numbers.
I think this algorythm  can be better than the mersenne algorythm.
The proof have to be done...


Code :
Code: BlitzMax
  1. Local cpt:Long=0
  2.  
  3. Local i:Long=0
  4.  
  5. Local k:Long=0
  6.  
  7.  
  8. a$=Input("Nombre multiple de 6 ou 'q' pour quitter (Number multiple of 6 or 'q' to quit)  :")
  9.  
  10. If Lower(a$)="q" Then End
  11.  
  12. cpt=Long(a$)
  13.  
  14. i=5
  15. flag=0
  16. While flag=0
  17.                 k=cpt+i
  18.                 flag=IsPremier(k)
  19.                 If KeyDown(KEY_ESCAPE)=True Then End
  20.                 If flag=1
  21.                         Print cpt+" + "+i+" = "+(cpt+i)+" est premier (is prime)"
  22.                 Else
  23.                         Print cpt+" + "+i+" = "+(cpt+i)+" n'est PAS premier (is not prime)"
  24.                         i=i+1
  25.                         While IsPremier(i)=0
  26.                                 If KeyDown(KEY_ESCAPE)=True Then End
  27.                                 i=i+1
  28.                         Wend
  29.                 EndIf
  30. Wend
  31.  
  32. End
  33.  
  34.  
  35. SetClsColor 0,0,0
  36. Cls
  37. SetColor 255,255,255
  38.  
  39. Function IsPremier(a:Long)
  40.         Local j:Long
  41.         If a=0 Then Return 0
  42.         If a=1 Then Return 0
  43.         If a=2 Then Return 1
  44.         If (a Mod 2)=0 Then Return 0
  45.         For j=1 To Long((a-3)/2)
  46.                 If KeyDown(KEY_ESCAPE)=True Then End
  47.                 If (a Mod (j+1))=0 Then Return 0
  48.         Next
  49.         Return 1
  50. EndFunction


Comments :


Vignoli(Posted 1+ years ago)

 After an adaptation of the source code, you can find a big prime number like this (with a supercalculator) :6*(10^10.000.000)+p is prime, with p as a prime number, testing if the result is prime with p=5, p=7, p =11, etc...100000$ are offered by a company on the web to find a number like this.But money go to money... (tears...lol) because a supercalculator is very expensive !!!


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal