Fermat pseudoprime/Code

From Citizendium
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This article is developing and not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
Code [?]
 
A collection of code samples relating to the topic of Fermat pseudoprime.

The following Sourcecode is the Heart of all calculating fermat pseudoprime-, euler pseudoprime- and strong pseudoprime programs:

/* REXX-Programm */
say 'Only a Library!'
exit 1
/* */
/* */
m_u: procedure
  arg a,l,m
/* initialisierung */
  as = a
  ai = a
  li = (l-1)
  DO li
    a = a * ai
    a = a // m
  END
return a

mod_up.r

A sourcecode to calculate fermat pseudoprimes

/* Ein REXX-Programm */

call load 'mod_up.r'
anzfpspr=0
do i = 2 to 99999
  fpsprb.i = " "
  t=0
  t2=0
  do i2 = 2 to (i-2)
    call m_u i2, (i-1), i
    pt = result
    if (pt = 1) then do
                        t = 1
                        fpsprb.i2 = fpsprb.i2||i||", "
    end
    if (pt > 1) then t2 = 1
  end
  tg = t + t2
  if (tg = 2) then do
                     anzfpspr = anzfpspr + 1
                     ausgabe = "fpspr."||anzfpspr||" = "||i
                     say ausgabe
                     lineout("epspr_var.txt",ausgabe)
  end
end
lineout("fpsprb_table2.txt","{| {{prettytable}")
do i = 2 to 99999
  ausgabe = "|"||i||" ||"||fpsprb.i||"@"
  say ausgabe
  lineout("fpsprb_table2.txt",ausgabe)
  lineout("fpsprb_table2.txt","|-")
end

The File "epspr_var.txt" is used to calculate euler pseudoprimes. The file "fpsprb_table2.txt" is a table in Wikimedia format.