• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
48%
SHARE
TWEET

# mers.pl

a guest Jan 10th, 2013 1,133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #!/usr/bin/perl
2.
3. # # # # # # # # # # # #
4. # # # # # # # bullshit
5.
6.
7. for (\$i = 0; \$i < 80; \$i++)
8.         {
9.         print "\n";
10.         }
11.
12.
13. print "mersenne tester\n";
14. print "\n";
15. print "\n";
16. print "format: 2^p-1\n";
17. print "if 2^p-1 is prime, it is a mersenne prime\n";
18.
19. # # # # # # # # # # # # # #
20. # # # # # # get information
21.
22. \$p = 0;
23. \$number = 0;
24. \$half = 0;
25. \$count = 0;
26. \$divisor = 0;
27.
28. \$count_two = 0;
29.
30. \$divisor = 2;
31.
32.
33. # # # # # # # # # # # # #
34. # # # # # # begin testing
35.
36. print "enter p:\n";
37. \$p = <STDIN>;
38.
39. \$number = (2 ** \$p) -1;
40.
41. print "you entered ", \$p, " 2^p is ", (\$number + 1), " and number \= \$number\n";
42.
43. \$half = \$number / 2;
44.
45. print "testing\n";
46.
47. \$count_two = 1;
48.
49. for (\$count=1; \$count<\$half; ++\$count)
50.         {
51.         ++\$count_two;
52.         if(\$number % \$divisor == 0)
53.                 {
54.                 print "2^", \$p, "-1 is not a mersenne prime.\n";        # # # # # # # # # # # #
55.                 print "it took \$count_two passes to complete,\n";       # # # # # # # # too bad
56.                 print "and was divided by ", \$divisor, ".\n";
57.                 exit(0);
58.                 }
59.                 else
60.                 {
61.                         if(\$number % \$divisor > 0)
62.                         {
63.                         ++\$divisor;
64.                         }
65.                 }
66.         }
67.
68. # # # # # # # # # # # #
69. # # # # # # # # success
70.
71. print "\n";
72. print "2^", \$p, "-1 is a mersenne prime.\n";
73. print "it took \$count_two passes to complete.\n";
RAW Paste Data
Top