Advertisement
everblut

Numeros Primos

Mar 8th, 2011
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.28 KB | None | 0 0
  1. #! usr/bin/ruby
  2. # numeros primos
  3.  
  4. puts 'Inserta el numero que quieras comprobar si es primo'
  5. STDOUT.flush
  6. n = gets.chomp
  7. num = n.to_i
  8. i = 2
  9. while i < num do
  10.  
  11.  if num % i == 0
  12.    print 'no es primo \n'
  13.    break
  14.  else
  15.    puts num, " es primo\n"
  16.    break
  17.  
  18.  end
  19. i += 1
  20.  
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement