Sha256: c29098eac185e72770d810467cc0f621dca97c7e24dc7029e365f47319b4b755

Contents?: true

Size: 979 Bytes

Versions: 26

Compression:

Stored size: 979 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))
})

print("All tests passed for exercise: prime-factors")

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
trackler-2.1.0.48 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.47 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.46 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.45 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.44 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.43 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.42 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.41 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.40 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.39 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.38 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.37 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.36 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.34 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.33 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.32 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.31 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.30 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.29 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.1.0.28 tracks/r/exercises/prime-factors/test_prime-factors.R