Skip to content

Instantly share code, notes, and snippets.

@dbhalling
Last active August 24, 2018 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbhalling/8670b4d5ce19b8270ed1495cb98cd140 to your computer and use it in GitHub Desktop.
Save dbhalling/8670b4d5ce19b8270ed1495cb98cd140 to your computer and use it in GitHub Desktop.
Codility CountNonDivisible 32
#Codility CountNonDivisible 32
a = [3, 1, 2, 3, 6]
def solution(a)
# length = a.count
count = 0
i = 0
aresult = []
while i < a.count
a.each do |x|
if a[i].modulo(x) != 0
count += 1
else
end
end
aresult.push(count)
count = 0
i += 1
end
return aresult
end
puts "The CountNonDivisible array is #{solution(a)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment