Question 1

How many prime numbers are in the number 2013?

# install.packages(c("tidyverse","pracma"))
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(pracma)
## 
## Attaching package: 'pracma'
## 
## The following object is masked from 'package:purrr':
## 
##     cross
our_number <- "2013"
digits <- as.numeric(strsplit(our_number,"")[[1]])
q1_data <- data.frame(Digit = digits)
answer <- q1_data %>%
  mutate(Prime = isprime(Digit)) %>%
  filter(Prime == TRUE) %>%
  count() %>%
  pull(n)
cat("There are",answer,"prime numbers in the number 2013.","\n")
## There are 2 prime numbers in the number 2013.

Question 2

If \(f(x) = \frac{1}{x^3 - 3x^2}\), what is \(f'(x)\)?

# install.packages("Deriv")
library(Deriv)
f <- function(x) {
  1 / (x^3 - 3 * x^2)
}
f_prime <- Deriv(f)
f_prime
## function (x) 
## {
##     .e1 <- x - 3
##     -(x * (2 * .e1 + x)/(x^2 * .e1)^2)
## }