You are on page 1of 14

1.

R Program to Generate Random Number from Standard Distributions

Uniform Distribution

Normal Distribution

2. R Script for Sample From a Population

Sample 2 items from x

3. R Program to find Minimum and Maximum


4. R Program to sort a vector

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To
sort in descending order we can pass decreasing=TURE.

Sometimes we would want the index of the sorted vector instead of the values. In such case we can
use the function order().

5. R Program to Find the Factorial of a Number


Output:

6. R Program to print multiplication table

Output:

7. R Program to check Prime Number


Output 1 :

Output 2:

8. R Program to check Armstrong Number


Output 1:

Output 2:

9. R Program to print Fibonacci Series


Output:

10. R Program to check for a Leap Year.


Output 1:

Output 2:

If a year is divisible by 4, 100 and 400, it's a leap year.

If a year is divisible by 4 and 100 but not divisible by 400, it's not a leap year.

If a year is divisible by 4 but not divisible by 100, it's a leap year.

If a year is not divisible by 1, it's not a leap year.

This logic is implemented in the above program using nested if...else statement.

11. Check if a Number is Odd or Even in R Programming


Output 1:

Output 2:

12. Check if a Number is Positive, Negative or Zero

Output 1:

Output 2:

13. R Program to Find the Sum of Natural Numbers


i) Find sum of natural numbers without formula

Output:

ii) Find sum of natural numbers using a formula

Output:

14. Convert Decimal into Binary using Recursion in R


Output:

15. R Program to Find the Factorial of a Number Using Recursion

Output:

16. R Program to Find the Factors of a Number

Output:
17. Fibonacci Sequence Using Recursion in R

Output:
18. R Program to Find H.C.F.

Output:

19. R Program to Find L.C.M.


Output:

20. Sum of Natural Numbers Using Recursion

Output:

You might also like