Author 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) }...

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