Day: February 5, 2021

R Examples for Beginners – Sum of Natural Numbers Using Recursion

(R Example for Citizen Data Scientist & Business Analyst)   Sum of Natural Numbers Using Recursion In this example, you’ll learn to find the sum of natural numbers using recursion. To solve this problem, a recursive function calculate_sum() function is created.   Example: Sum of Natural Numbers # Program to find the sum of natural …

R Examples for Beginners – R Program to Make a Simple Calculator

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Make a Simple Calculator In this example, you will learn to create a simple calculator that can add, subtract, multiply and divide two numbers entered by the user.   Example: Simple Calculator in R # Program make a simple calculator that can …

R Examples for Beginners – R Program to Find L.C.M.

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find L.C.M. In this example, you will learn to find the L.C.M of two numbers entered by the user by creating a user-defined function. The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by …

R Examples for Beginners – R Program to Find H.C.F. or G.C.D

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find H.C.F. or G.C.D In this article, you will learn to find the GCD (Greatest Common Divisor) by creating a user-defined function in two different ways. The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest …

R Examples for Beginners – Fibonacci Sequence Using Recursion in R

(R Example for Citizen Data Scientist & Business Analyst)   Fibonacci Sequence Using Recursion in R In this article, you find learn to print the fibonacci sequence by creating a recursive function, recurse_fibonacci(). The first two terms of the Fibonacci sequence is 0 followed by 1. All other terms are obtained by adding the preceding …

R Examples for Beginners – R Program to Find the Factors of a Number

(R Example for Citizen Data Scientist & Business Analyst) R Program to Find the Factors of a Number In this example, you’ll learn to find all factors of an number (entered by the user) using for loop and if statement.   Example: Find factors of a number print_factors <- function(x) { print(paste(“The factors of”,x,”are:”)) for(i …

R Examples for Beginners – R Program to Find the Factorial of a Number Using Recursion

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find the Factorial of a Number Using Recursion In this example, you’ll learn to find the factorial of a number using a recursive function.   The factorial of a number is the product of all the integers from 1 to the number. …

R Examples for Beginners – Convert Decimal into Binary using Recursion in R

(R Example for Citizen Data Scientist & Business Analyst)   Convert Decimal into Binary using Recursion in R In this example, you will learn to convert decimal number into binary by creating a recursive function, convert_to_binary().   Example: Binary to Decimal # Program to convert decimal number into binary number using recursive function convert_to_binary <- …

R Examples for Beginners – R Program to Find the Sum of Natural Numbers

(R Example for Citizen Data Scientist & Business Analyst)   R Program to Find the Sum of Natural Numbers In this example, you’ll learn to find the sum of natural numbers entered by the user. The example uses a while loop to calculate the sum.   Example 1: Find sum of natural numbers without formula …

R Examples for Beginners – Check if a Number is Positive, Negative or Zero

(R Example for Citizen Data Scientist & Business Analyst)   Check if a Number is Positive, Negative or Zero In this example, a number entered by the user is checked whether it’s a positive number or a negative number or zero.   Example: Check Positive, Negative or Zero # In this program, we input a …