# Category Archives

The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the...

#### Write a R Program to Find LCM

The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the...

The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest positive integer that...

#### Write a R Program to Find GCD

The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest positive integer that...

print_factors <- function(x) { print(paste(“The factors of”,x,”are:”)) for(i in 1:x) { if((x %% i) == 0) { print(i) }...

#### Find factors using R Programming Language

print_factors <- function(x) { print(paste(“The factors of”,x,”are:”)) for(i in 1:x) { if((x %% i) == 0) { print(i) }...

Without Formula: num = as.integer(readline(prompt = “Enter a number: “)) if(num < 0) { print(“Enter a positive number”) }...

#### Find sum of natural numbers without/with formula using R Programming Languge

Without Formula: num = as.integer(readline(prompt = “Enter a number: “)) if(num < 0) { print(“Enter a positive number”) }...

An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of the...

#### Check Armstrong number or Not in R Programming Language

An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of the...

year = as.integer(readline(prompt=”Enter a year: “)) if((year %% 4) == 0) { if((year %% 100) == 0) { if((year...

#### Leap year or not in R Programming Language

year = as.integer(readline(prompt=”Enter a year: “)) if((year %% 4) == 0) { if((year %% 100) == 0) { if((year...

The factorial of a number is the product of all the integers from 1 to that number. For example,...

#### Factorial of a number in R Programming Language

The factorial of a number is the product of all the integers from 1 to that number. For example,...

nterms = as.integer(readline(prompt=”How many terms? “)) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print(“Plese enter a positive integer”) } else { if(nterms == 1) { print(“Fibonacci sequence:”) print(n1) } else { print(“Fibonacci sequence:”) print(n1) print(n2) while(count

#### Fibonacci Sequence in R Programming Language

nterms = as.integer(readline(prompt=”How many terms? “)) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print(“Plese enter a positive integer”) } else { if(nterms == 1) { print(“Fibonacci sequence:”) print(n1) } else { print(“Fibonacci sequence:”) print(n1) print(n2) while(count

num = as.integer(readline(prompt = “Enter a number: “)) # use for loop to iterate 10 times for(i in 1:5)...

#### Multiplication Table in R Programming Language

num = as.integer(readline(prompt = “Enter a number: “)) # use for loop to iterate 10 times for(i in 1:5)...

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort...

#### Sort a vector in R Programming Language

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort...

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x...

#### Find the position of minimum and maximum of value in R Programming Language

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x...

x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

#### Find the maximum and minimum number in R Programming Language

x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or...

#### Write a R Program to Two vector Variables (Addition, Subtraction, Multiplication, Division, Mod, Coefficient)

x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or...

2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 ...

#### R Programs to Add, Sub, Mul, and Div

2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 ...

First R Program: print (“Hello world!”) Output: “Hello world!” print (“Hello World!”, quote-FALSE) Output: Hello...

#### Simple way:” Hello world program in R”

First R Program: print (“Hello world!”) Output: “Hello world!” print (“Hello World!”, quote-FALSE) Output: Hello...