-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathfizzbuzz.Rmd
More file actions
48 lines (41 loc) · 1.07 KB
/
fizzbuzz.Rmd
File metadata and controls
48 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "Fizzbuzz"
author: "Matt"
date: "2/12/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
This document contains student solutions to the fizzbuzz problem. Students will add to this file using the outline below. Write your name (using three hashtags), then below create an R code block and insert your code. Save the .rmd file, then knit the document to update the html output. Then submit a pull request to merge your changes to the main repository.
### Jeff Kravitz
```{r}
total <- 1
for (i in 2:100) {
if (i %% 3 == 0) {
if (i %% 5 == 0) {
total <- paste(total,"FizzBuzz", sep = ", ")
}
else {
total <- paste(total,"Fizz", sep = ", ")
}
}
else if (i %% 5 == 0) {
total <- paste(total, "Buzz", sep = ", ")
}
else {
total <- paste(total, i, sep = ", ")
}
}
print(total)
```
### Matt's Code
```{r,eval=F}
answer <- 1:100
for(i in 1:100){
if(i%%3 == 0) answer[i] <-"fizz"
if(i%%5 == 0) answer[i] <-"buzz"
if(i%%5 == 0 & i%%3 ==0) answer[i] <-"fizzbuzz"
}
print(answer)
```