If you want to start learning the R programming or you have a bit knowledge about R programming, then this tutorial will help you to explore more. In this tutorial, we are going to share a **R program to find the factors of a number** with an example.

R is a famous programming language which is widely used for data analysis by data scientists. It is used in major companies like Google, Airbnb, Facebook etc.

Copy the below code and execute it to see the program output.

1 2 3 4 5 6 7 8 | print_factors <- function(x) { print(paste("The factors of",x,"are:")) for(i in 1:x) { if((x %% i) == 0) { print(i) } } } |

print_factors(120)

[1] “The factors of 120 are:”

[1] 1

[1] 2

[1] 3

[1] 4

[1] 5

[1] 6

[1] 8

[1] 10

[1] 12

[1] 15

[1] 20

[1] 24

[1] 30

[1] 40

[1] 60

[1] 120

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- R Program to Find L.C.M.
- Sum of Natural Numbers Using Recursion
- r program for factorial using recursion
- R program to find L.C.M. with the output
- R program to take input from user with the output
- Convert decimal into binary using recursion in R
- Odd or Even program in R programming
- R program to check armstrong number
- R program to find the sum of natural numbers
- r practice problems for beginners

We use cookies to ensure that we give you the best experience and use cookies in order to personalize the advertising that you see on our website. Read more about our Privacy Policy.Got it!