Sha256: bc8079becea8189876ebdd8edf19bf60b9aa3ac3d2588a322265451a8004711a

Contents?: true

Size: 981 Bytes

Versions: 140

Compression:

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

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

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
trackler-2.2.1.85 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.84 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.83 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.82 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.81 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.80 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.79 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.78 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.77 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.76 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.75 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.74 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.73 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.72 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.71 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.70 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.69 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.68 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.67 tracks/r/exercises/prime-factors/test_prime-factors.R
trackler-2.2.1.66 tracks/r/exercises/prime-factors/test_prime-factors.R