verence
04. November 2017
(Simple and short) Definition of devisors:
A divisor divids an integer number with a remainder of 0. So every number has several divisors.
Examples:
(Simple and short) Definition of prime number: A prime number can only divided by 1 and it self with a remainer of 0.
Examples:
Following function used on server side in the shiny application to compute the divisors of number X:
# divisor function
divisor_vector <- function(x){
# Vector of numberes to test against
y <- seq_len(ceiling( x / 2 ) )
# special handling for number 1
if (x != 1) { y <- c(y,x)}
# Modulo division. If remainder is 0 that number is a divisor of x so return it
y[ x%%y == 0 ]
}
divisor_vector(12) # example
[1] 1 2 3 4 6 12
The small shiny web application Divisors and Prime Numbers visualize in a plot:
Short impression