mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-20 10:26:17 +01:00
prime number: review comments-2 implementation
This commit is contained in:
parent
f1325f32bc
commit
00d1ed0973
1 changed files with 1 additions and 8 deletions
|
@ -8,14 +8,7 @@ def is_prime_number(number)
|
|||
if number == 1
|
||||
prime_flag = true
|
||||
else
|
||||
factors = 2
|
||||
while factors.to_i <= number.to_i/2
|
||||
if number.to_i % factors.to_i==0
|
||||
prime_flag = true
|
||||
break
|
||||
end
|
||||
factors+=1
|
||||
end
|
||||
prime_flag = (2..number/2).any? { |i| number % i == 0 }
|
||||
end
|
||||
else
|
||||
prime_flag = true
|
||||
|
|
Loading…
Reference in a new issue