0% found this document useful (0 votes)
31 views

Assignment: Class XI Computer Science Functions

The document describes 14 programming assignments involving writing functions to perform calculations and check properties of numbers. The functions include calculating factorials, powers, and series sums, finding logarithms, greatest common factors, least common multiples, and converting between decimal, binary, hexadecimal, and Roman numeral systems. Other functions check if a number is happy, Armstrong, part of a Hailstone sequence, circular prime, or an Adams number.

Uploaded by

Baichitra Mondal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment: Class XI Computer Science Functions

The document describes 14 programming assignments involving writing functions to perform calculations and check properties of numbers. The functions include calculating factorials, powers, and series sums, finding logarithms, greatest common factors, least common multiples, and converting between decimal, binary, hexadecimal, and Roman numeral systems. Other functions check if a number is happy, Armstrong, part of a Hailstone sequence, circular prime, or an Adams number.

Uploaded by

Baichitra Mondal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment

Class XI
Computer Science
Functions
1. Write a program to calculate the sum of the following series
X+ X2/2! + X3/3!....Xn/n!
To Calculate the above series write at least 3 functions
(a) Function to calculate Factorial of a number
(b) Function to Calculate Power of a number
(c) Function to find Sum of the series
2. Write a program to calculate the sum of the following series
X+ X2/3! + X3/5!....Xn/(2n-1)!
To Calculate the above series write at least 3 functions
(a) Function to calculate Factorial of a number
(b) Function to Calculate Power of a number
Function to find Sum of the series
3. Write a program to calculate the sum of the following series
X- X2/3! + X3/5!-X4/7!....Xn/(2n-1)!
To Calculate the above series write at least 3 functions
(a) Function to calculate Factorial of a number
(b) Function to Calculate Power of a number
Function to find Sum of the series
4. Write a function to calculate Log of a number passed as function argument.
Note:-Do not use system defined functions for calculation
5. Write a Function to calculate the HCF of two numbers using long division
method.
6. Write a function to Calculate LCM of two numbers without calculating HCF.
7. Write a function in Python which takes a decimal number as input and
calculates the ROMAN equivalent of that number
8. Write a function in Python which takes one decimal number as input and
calculates the binary equivalent of that number
Note:- Do not use system defined functions for calculation
9. Write a function in Python which takes a decimal number as argument and
calculates the Hexadecimal equivalent of that number
Note:- Do not use system defined functions for calculation
10. Write function in Python which takes one integer as function argument and
checks whether the number is HAPPY number or not Definition: A happy
number is a number defined by the following process: Starting with any
positive integer, replace the number by the sum of the squares of its digits,
and repeat the process until the number equals 1 (where it will stay), or it
loops endlessly in a cycle which does not include 1. Example:- 1, 7, 10, 13,
19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, Take 97= 92 +
72 =130 = 12 + 32 + 02 = 10 = 12 + 02 = 1 so 97 is a happy number
11. Write a function in python which takes one integer as function argument and
checks whether the number is Armstrong number or not.

Definition: An Armstrong number is any number of n digits which is equal to


the sum of nth power of digits in the number. Generally in most
programming cases we consider numbers from 000 to 999 that is 3 digit
numbers. Thus, we also define Armstrong number is any number of 3 digits
as sum of cubes of digits in number. For example: 3 digit Armstrong number
153=(1*1*1)+(5*5*5)+(3*3*3) 4 digit Armstrong number
1634=(1*1*1*1)+(6*6*6*6)+(3*3*3*3)+(4*4*4*4)
12. Write a function which takes a number N as function argument and displays
the Hailstone sequence of that number, the display should stop when the
sequence reaches 1

Definition: The Hailstone sequence of numbers can be generated from a


starting positive integer, n by: If n is 1 then the sequence ends. If n is even
then the next n of the sequence = n/2 If n is odd then the next n of the
sequence = (3 * n) + 1 The (unproven) Collatz conjecture is that the
hailstone sequence for any starting number always terminates. The hailstone
sequence is also known as hailstone numbers (because the values are usually
subject to multiple descents and ascents like hailstones in a cloud). This
sequence is also known as the Collatz sequenc Input : N = 7 5 Output :
Hailstone Numbers: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
No. of steps Required: 17 Input : N = 9 Output : Hailstone Numbers: 9, 28,
14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 No. of steps
Required: 20 In the first example, N = 7. The numbers will be calculated as
follows: 7 3 * 7 + 1 = 22 // Since 7 is odd. 22 / 2 = 11 // 22 is even. 3 * 11 +
1 = 34 // 11 is odd. .... and so on upto 1.
13. Write a function which takes one number as function argument and checks
whether the number is circular-prime number or not.

Definition: A circular prime is a prime number with the property that the
number generated at each intermediate step when cyclically permuting its
(base 10) digits will be prime. For example, 1193 is a circular prime, since
1931, 9311 and 3119 all are also prime. The first few circular primes are 2, 3,
5, 7, 11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 197,
14. Write a function to check whether the number taken as function argument is
Adams Number or not.

Definition: Adam number is a number when reversed, the square of the


number and the square of the reversed number should be numbers which are
reverse of each other. Adam numbers upto 1000 are: 0, 1, 2, 3, 11, 12, 13, 21,
22, 31, 101, 102, 103, 111, 112 , 113, 121, 122, 201, 202, 211, 212, 221, 301,
311 Example: 13 is Adams number 132 =169 reverse of 169=961 and √961=
31 which is reverse of the original i.e 13

You might also like