SHARE
TWEET

Untitled

a guest Jun 16th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env ruby
  2.  
  3. def sieve(num);
  4.  
  5.       n = num;
  6.       array_seed = [];
  7.  
  8.       while n > 1 do
  9.    γ€€γ€€γ€€γ€€γ€€array_seed << n;
  10. γ€€γ€€γ€€   γ€€γ€€n -= 1;
  11.       end
  12.  
  13.       array_seed.reverse!;
  14.       primes = [];
  15.  
  16.       while true do
  17. γ€€γ€€γ€€   γ€€γ€€array_seed_tmp = array_seed.shift;
  18. γ€€γ€€γ€€γ€€γ€€   primes << array_seed;
  19.  
  20.            break if !array_seed_tmp
  21.  
  22.            trashnum = [];
  23.  
  24.            array_seed.each do |x|
  25.                trashnum << x; if x % array_seed_tmp == 0
  26.            end
  27.          primes -= trashnum
  28. γ€€    end
  29.       array_string = primes.to_s;
  30.       array_string.each do |y|
  31.          print("#{y}s");
  32.       end
  33.     end
  34. end
  35.      
  36. psieve.rb(main):001:0> #!/usr/bin/env ruby
  37. => nil
  38. psieve.rb(main):002:0>
  39. psieve.rb(main):003:0> def sieve(num);
  40. psieve.rb(main):004:1>  
  41. psieve.rb(main):005:1>       n = num;
  42. psieve.rb(main):006:1>       array_seed = [];
  43. psieve.rb(main):007:1>
  44. psieve.rb(main):008:1>       while n > 1 do
  45. psieve.rb(main):009:2*    γ€€γ€€γ€€γ€€γ€€array_seed << n;
  46. psieve.rb(main):010:2> γ€€γ€€γ€€   γ€€γ€€n -= 1;
  47. psieve.rb(main):011:2>       end
  48. psieve.rb(main):012:1>
  49. psieve.rb(main):013:1>       array_seed.reverse!;
  50. psieve.rb(main):014:1>       primes = [];
  51. psieve.rb(main):015:1>
  52. psieve.rb(main):016:1>       while true do
  53. psieve.rb(main):017:2* γ€€γ€€γ€€   γ€€γ€€array_seed_tmp = array_seed.shift;
  54. psieve.rb(main):018:2> γ€€γ€€γ€€γ€€γ€€   primes << array_seed;
  55. psieve.rb(main):019:2>          
  56. psieve.rb(main):020:2>            break if !array_seed_tmp
  57. psieve.rb(main):021:2>        
  58. psieve.rb(main):022:2>            trashnum = [];
  59. psieve.rb(main):023:2>
  60. psieve.rb(main):024:2>            array_seed.each do |x|
  61. psieve.rb(main):025:3*                trashnum << x; if x % array_seed_tmp == 0
  62. psieve.rb(main):026:4>            end
  63. psieve.rb(main):027:3>          primes -= trashnum
  64. psieve.rb(main):028:3> γ€€    end
  65. psieve.rb(main):029:2>       array_string = primes.to_s;
  66. psieve.rb(main):030:2>       array_string.each do |y|
  67. psieve.rb(main):031:3*          print("#{y}s");
  68. psieve.rb(main):032:3>       end
  69. psieve.rb(main):033:2>     end
  70. psieve.rb(main):034:1> end
  71. => :sieve
  72. psieve.rb(main):035:0>
  73. psieve.rb(main):036:0>
  74.      
  75. #!/usr/bin/env ruby
  76.  
  77. def sieve(num);
  78.  
  79.       n = num;
  80.       array_seed = [];
  81.  
  82.       while n > 1 do
  83.    γ€€γ€€γ€€γ€€γ€€array_seed << n;
  84. γ€€γ€€γ€€   γ€€γ€€n -= 1;
  85.       end
  86.  
  87.       array_seed.reverse!;
  88.       primes = [];
  89.  
  90.       while true do
  91. γ€€γ€€γ€€   γ€€γ€€array_seed_tmp = array_seed.shift;
  92. γ€€γ€€γ€€γ€€γ€€   primes << array_seed;
  93.  
  94.            break if !array_seed_tmp
  95.  
  96.            trashnum = [];
  97.  
  98.            array_seed.each do |x|
  99.                trashnum << x; if x % array_seed_tmp == 0
  100.            end
  101.          primes -= trashnum
  102. γ€€    end
  103.       array_string = primes.to_s;
  104.       array_string.each do |y|
  105.          print("#{y}s");
  106.       end
  107.     #end
  108. end
  109.      
  110. psieve.rb(main):001:0> #!/usr/bin/env ruby
  111. => nil
  112. psieve.rb(main):002:0>
  113. psieve.rb(main):003:0> def sieve(num);
  114. psieve.rb(main):004:1>  
  115. psieve.rb(main):005:1>       n = num;
  116. psieve.rb(main):006:1>       array_seed = [];
  117. psieve.rb(main):007:1>
  118. psieve.rb(main):008:1>       while n > 1 do
  119. psieve.rb(main):009:2*    γ€€γ€€γ€€γ€€γ€€array_seed << n;
  120. psieve.rb(main):010:2> γ€€γ€€γ€€   γ€€γ€€n -= 1;
  121. psieve.rb(main):011:2>       end
  122. psieve.rb(main):012:1>
  123. psieve.rb(main):013:1>       array_seed.reverse!;
  124. psieve.rb(main):014:1>       primes = [];
  125. psieve.rb(main):015:1>
  126. psieve.rb(main):016:1>       while true do
  127. psieve.rb(main):017:2* γ€€γ€€γ€€   γ€€γ€€array_seed_tmp = array_seed.shift;
  128. psieve.rb(main):018:2> γ€€γ€€γ€€γ€€γ€€   primes << array_seed;
  129. psieve.rb(main):019:2>          
  130. psieve.rb(main):020:2>            break if !array_seed_tmp
  131. psieve.rb(main):021:2>        
  132. psieve.rb(main):022:2>            trashnum = [];
  133. psieve.rb(main):023:2>
  134. psieve.rb(main):024:2>            array_seed.each do |x|
  135. psieve.rb(main):025:3*                trashnum << x; if x % array_seed_tmp == 0
  136. psieve.rb(main):026:4>            end
  137. psieve.rb(main):027:3>          primes -= trashnum
  138. psieve.rb(main):028:3> γ€€    end
  139. psieve.rb(main):029:2>       array_string = primes.to_s;
  140. psieve.rb(main):030:2>       array_string.each do |y|
  141. psieve.rb(main):031:3*          print("#{y}s");
  142. psieve.rb(main):032:3>       end
  143. psieve.rb(main):033:2>     #end
  144. psieve.rb(main):034:2> end
  145. psieve.rb(main):035:1>
  146. psieve.rb(main):036:1>
  147. SyntaxError (psieve.rb:35: syntax error, unexpected end-of-input, expecting end)
  148.     from /usr/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
  149.     from /usr/bin/irb:23:in `load'
  150.     from /usr/bin/irb:23:in `<main>'
  151.      
  152. #!/usr/bin/env ruby
  153.  
  154. def sieve(num)
  155.  
  156.         n = num;
  157.         array_seed = [];
  158.  
  159.         while n > 1 do
  160.                 array_seed << n;
  161.                 n -= 1;
  162.         end
  163.  
  164.         array_seed.reverse!;
  165.         primes = [];
  166.  
  167.         while true do
  168.                 array_seed_tmp = array_seed.shift;
  169.                 primes << array_seed;
  170.  
  171.                 break if !array_seed_tmp
  172.  
  173.                 trashnum = [];
  174.  
  175.                 array_seed.each do |x| trashnum << x;
  176.                         if x % array_seed_tmp == 0
  177.                         end
  178.                         primes -= trashnum
  179.                 end
  180.                 array_string = primes.to_s;
  181.                 array_string.each do |y|
  182.                         print("#{y}s");
  183.                 end
  184.         end
  185. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top