Hello Friends Today, through this tutorial, I will tell you how to generate a 4-digit random unique OTP number using R Language Program?
In R, you can generate a 4-digit random OTP (One-Time Password) using the `sample` function. Here's an example:
# Set the seed for reproducibility (optional)
set.seed(123)
# Generate a 4-digit random OTP
otp <- sample(0:9, 4, replace = TRUE)
# Convert the OTP to a string and concatenate
otp_str <- paste(otp, collapse = "")
# Print the generated OTP
cat("Your 4-digit OTP:", otp_str, "\n")
This code will generate a random 4-digit OTP each time you run it. Adjust the seed if you want reproducible results.