R Program to Find the Factors of a Given Number

R Program to Find the factors of a given number: In this program, you will learn about the R program to find the factors of a given number.

R Program to Find the Factors of a Given Number

Source Code

print_factors = function(n) {
print(paste("factor",n,"are:"))
for(i in 1:n) {
if((n %% i) == 0) {
print(i)
}
}
}
print_factors(4)
print_factors(7)
print_factors(12)

Output