Programs to try using Functions in R - Assignment 3
Program List
Functions
1.Write a program to compute nCr, using a factorial function
2. Write a function to print the fibonacci numbers between a lower bound and an upper bound
3.Find the binary equivalent of each digit of a number(ie;BCD each digit is represented as 4 bit binary). Use a separate function to find binary.
4.Find the sum of the cosine series 1-x^2/2!+x^4/4!-x^6/6!......n terms.Use a function fact to find the factorial of the number
5.Write a R function is_prime(n), which returns True if the number n is a prime and returns False, if the number n is not prime.Use the is_prime(n) function to generate first N prime numbers
6.Write a pow(x,y) function to compute x^y.Use this function to convert an octal number to decimal.
Recursive Functions
1.Write a function to find the greatest common divisor (GCD) of two numbers.(use euclid algorithm)
Use this function to find LCM.
2.Write a recursive function to reverse a number.
3.Write a recursive function to find the sum of digits of a number.
2.Write a recursive function to reverse a number.
3.Write a recursive function to find the sum of digits of a number.
4. Write a recursive functions to compute the sum and product of two numbers using repeated addition.
5. Write a recursive function to convert a decimal number to binary. 6. Write a recursive function to calculate the n'th term of the Fibonaci sequence.Use this function to generate Fibonaci numbers less than 100.
7. Use recursive factorial function to compute nPr.
Comments
Post a Comment