Euler pseudoprime/Code

From Citizendium
< Euler pseudoprime
Revision as of 04:10, 6 January 2008 by imported>Karsten Meyer (typo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This article is a stub and thus not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
Code [?]
 
A collection of code samples relating to the topic of Euler 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 euler pseudoprimes

/* Ein REXX-Programm */
call load 'mod_up.r'
fpspr.1 = 15 
fpspr.2 = 21 
fpspr.3 = 25 
fpspr.4 = 28 
fpspr.5 = 33 
fpspr.6 = 35 
fpspr.7 = 39 
fpspr.8 = 45 
fpspr.9 = 49
.
.
.
fpspr.5974 = 11620 
fpspr.5975 = 11623 
fpspr.5976 = 11625 
fpspr.5977 = 11627 
fpspr.5978 = 11629
anzfpspr = 5978
lineout("epspr_table2.txt","{| {{prettytable}")
do i=1 to anzfpspr
  i2ende = fpspr.i - 2
  q = fpspr.i // 2
  ausgabe = "|"||fpspr.i||" ||"
  do i2 = 2 to i2ende
    t.i2 = 0
    call m_u i2, ((fpspr.i - 1)), fpspr.i
    pt = result
    if (pt = 1) then do
                       t.i2 = pt
                       if (q = 1) then do
                                         call m_u i2, ((fpspr.i - 1)/2), fpspr.i
                                         pt = result
                                         t3.i2 = (pt-1)*(pt-(fpspr.i-1))
                                         if (t3.i2 = 0) then t.i2 = t.i2 + 1
                                       end
                     end
                    
    t2.i2 = pt
    if (t.i2 = 1) then ausgabe = ausgabe||i2||", "
    if (t.i2 = 2) then ausgabe = ausgabe||"'''"||i2||"''', "
  end
  ausgabe = ausgabe||"@"
  say ausgabe
  lineout("epspr_table2.txt",ausgabe)
  lineout("epspr_table2.txt","|-")
end

The List:

fpspr.1 = 15 
fpspr.2 = 21 
fpspr.3 = 25 
fpspr.4 = 28 
fpspr.5 = 33 
fpspr.6 = 35 
fpspr.7 = 39 
fpspr.8 = 45 
fpspr.9 = 49
.
.
.
fpspr.5974 = 11620 
fpspr.5975 = 11623 
fpspr.5976 = 11625 
fpspr.5977 = 11627 
fpspr.5978 = 11629

will be generate as "epspr_var.txt" by the following Souerce code to calculate the 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