Divisors and Prime Numbers

verence
11/04/2017

Introduction

(Simple and short) Definition of devisors:
A divisor divids an integer number with a remainder of 0. So every number has several divisors.

Examples:

  • 12 has divisors 1,2,3,4,6,12
  • 99 has divisors 1,3,9,11,33,99

(Simple and short) Definition of prime number: A prime number can only divided by 1 and it self with a remainer of 0.

Examples:

  • 17 has divisors 1,17
  • 97 has divisors 1,97

Calculation of Devisors:

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

Divisors and Prime Numbers

The small shiny web application Divisors and Prime Numbers visualize in a plot:

  • the divisor of given bunch of numbers
  • it also visualize the prime numbers
  • the plot has a dynamic range of 1..500

Shiny Web Application

Short impression sidebar Shiny web application - Divisors and Prime Numbers

Prime Numbers added to plot Doumentation