Simulate the factorable probability
Now we will use the is_factorable function that we wrote in the previous exercise to check factorability of many quadratics.
Specifically, we will check every combination of a, b and c where each value is between 1 and 100, using a nested for loop.
Bu egzersiz
Probability Puzzles in R
kursunun bir parçasıdırEgzersiz talimatları
- Write a nested
forloop, to loop each ofa,b, andcfrom the values 1 through 100. - For each combination of
a,bandc, check whether the quadratic is factorable.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
counter <- 0
# Nested for loop
for(___){
for(___){
for(___){
# Check whether factorable
if(___){
counter <- counter + 1
}
}
}
}
print(counter / 100^3)