R Program to Find H.C.F. or G.C.D.
Finds greatest common divisor via Euclidean algorithm.
[1] 12
Practice factorials, prime checks, Armstrong numbers, Fibonacci, leap year logic, GCD/LCM, sums, and tables. Emphasis on clear numeric utilities.
Finds greatest common divisor via Euclidean algorithm.
[1] 12
Computes factorial using a for loop.
[1] 120
Prints a multiplication table for a given number.
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50
Checks primality with trial division.
[1] TRUE
Checks if a number equals sum of cubes of its digits.
[1] TRUE
Generates Fibonacci numbers iteratively.
[1] 0 1 1 2 3 5 8 13 21 34
Checks leap year using standard rules.
[1] TRUE
Computes factorial recursively.
[1] 120
Generates first N Fibonacci numbers using recursion.
[1] 0 1 1 2 3 5 8 13 21 34
Computes least common multiple using GCD.
[1] 36
Concatenates strings using paste0.
[1] "Hello World"
main.R, then run Rscript main.R from your terminal. Alternatively, use an IDE such as RStudio.
R is a powerful language for data analysis, visualization, and statistical computing. Practicing small, focused programs builds fluency with vectors, data frames, lists, functions, control flow, and string manipulation.
On this page, you’ll find clean, well-formatted examples that run across platforms. Each example includes a short description and expected output so you can quickly verify your understanding. Explore the topics via the sidebar and extend the code to experiment further.
Whether you’re preparing for coursework, handling data tasks at work, or learning R for research, these examples offer a practical path to mastery. Bookmark the page and revisit to keep sharpening your skills.