Sha256: 2b7a597a86638225308265a90e600539fd8b048b1c90505cbf832acbf20301de

Contents?: true

Size: 973 Bytes

Versions: 28

Compression:

Stored size: 973 Bytes

Contents

source('./prime-factors.R')
suppressPackageStartupMessages({ library(testthat) })

test_that("no factors", {
  number <- 1
  expect_equal(prime_factors(number),
               c()
  )
})

test_that("prime number", {
  number <- 2
  expect_equal(prime_factors(number),
               c(2)
  )
})

test_that("square of a prime", {
  number <- 9
    expect_equal(prime_factors(number),
                 c(3, 3)
    )
})

test_that("cube of a prime", {
  number <- 8
    expect_equal(prime_factors(number),
                 c(2, 2, 2)
    )
})

test_that("product of primes and non-primes", {
  number <- 12
    expect_equal(prime_factors(number),
                 c(2, 2, 3)
    )
})

test_that("product of primes", {
  number <- 901255
    expect_equal(prime_factors(number),
                 c(5, 17, 23, 461)
    )
})
test_that("factors include a large prime", {
  number <- 93819012551
    expect_equal(prime_factors(number),
                 c(11, 9539, 894119)
    )
})

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
trackler-2.1.0.9 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.8 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.7 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.6 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.5 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.4 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.3 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.2 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.1 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.0 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.55 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.54 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.53 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.52 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.51 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.50 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.49 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.48 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.47 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.0.8.46 tracks/r/exercises/prime-factors/test_prime-factors.R