Sha256: 8702ba6958a90946bfa7a251d20c5dfe8c94c86abef97f7504490347b0c8df28

Contents?: true

Size: 666 Bytes

Versions: 219

Compression:

Stored size: 666 Bytes

Contents

raindrops <- function(number) {
  
  pling <- ''
  plang <- ''
  plong <- ''
  
  # If the number has 3 as a factor, output 'Pling'.
  if (number %% 3 == 0) {
    pling <- 'Pling'
  }
  # If the number has 5 as a factor, output 'Plang'.
  if (number %% 5 == 0) {
    plang <- 'Plang'
  }
  # If the number has 7 as a factor, output 'Plong'.
  if (number %% 7 == 0) {
    plong <- 'Plong'
  }
  
  plingplangplong <- paste(pling, plang, plong, sep = "")
  
  # If the number does not have 3, 5, or 7 as a factor, 
  # just pass the number's digits straight through
  if (plingplangplong == "") {
    plingplangplong <- as.character(number)
  }
  
  plingplangplong
}

Version data entries

219 entries across 219 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.179 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.178 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.177 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.176 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.175 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.174 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.173 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.172 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.171 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.170 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.169 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.167 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.166 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.165 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.164 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.163 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.162 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.161 tracks/r/exercises/raindrops/example.R
trackler-2.2.1.160 tracks/r/exercises/raindrops/example.R