library(ggplot2)
collatz_conjecture <- function(n) {
sequence <- c(n)
while (n != 1) {
if (n %% 2 == 0) {
n <- n / 2
} else {
n <- 3 * n + 1
}
sequence <- c(sequence, n)
}
return(sequence)
}
plot_collatz <- function(n) {
sequence <- collatz_conjecture(n)
df <- data.frame(
Step = seq_along(sequence),
Value = sequence
)
p <- ggplot(df, aes(x = Step, y = Value)) +
geom_line(color = "darkcyan") +
geom_point(color = "darkcyan", size = 1) +
labs(title = "Collatz conjecture", x = "Step", y = "Value") +
theme_minimal() +
theme(panel.grid.major = element_line(color = "gray90"),
panel.grid.minor = element_line(color = "gray95"))
print(p)
}
plot_collatz(27)Presentation example
Slideshow using Quarto and Reveal.js
🎯 Objectives
Tip
Metadata
The metadata of the current document is shown at the top of the page
transition: slide: choose transmition modechalkboard: true: activate chalkboardcontrols: true: show navigation arrows
Speaker View
::: {.notes}to add personal notesSto activateSpeaker View
Use :
- On your own screen: display Speaker View
- On the presentation screen: display the slideshow
Personal notes
- note 1
- note 2
Chalkboard
Bto open a blackboardCto draw on your slide
Lists
- item 1
- item 1.1
- item 1.2
- item 2
incrémental display
- item 3
- item 4
Table
| Number | Name | Main City |
|---|---|---|
| 01 | Ain | Bourg-en-Bresse |
| 02 | Aisne | Laon |
| 03 | Allier | Moulins |
| 04 | Alpes-de-Haute-Provence | Digne-les-Bains |
| 05 | Hautes-Alpes | Gap |
Code
collatz_conjecture <- function(n) {
sequence <- c(n)
while (n != 1) {
if (n %% 2 == 0) {
n <- n / 2
} else {
n <- 3 * n + 1
}
sequence <- c(sequence, n)
}
return(sequence)
}
plot_collatz <- function(n) {
sequence <- collatz_conjecture(n)
df <- data.frame(Step = seq_along(sequence), Value = sequence)
ggplot(df, aes(x = Step, y = Value)) +
geom_line(color = "darkcyan") +
geom_point(color = "darkcyan", size = 1) +
labs(title = "Collatz conjecture", x = "Step", y = "Value") +
theme_minimal()
}
plot_collatz(27)Big text
The r-fit-text class makes text as large as possible without overflowing the slide.
Big Text
Image size auto
Use class .r-stretch with your image to automatically adapt image size.
Animation
Animation
Implicit
Animation

