0% found this document useful (0 votes)
56 views4 pages

Exercise: Exercise 1: Calculate The Price TTC of An Item From Its Price HT, With A Rate of VAT To 19.6%

The document contains 22 math exercises involving calculating prices with tax, converting times to hours/minutes/seconds, calculating sequences, plotting functions, finding greatest common divisors, prime numbers, and more. The exercises provide algorithms and Scilab code to perform the calculations and demonstrate how to write functions to solve similar problems.

Uploaded by

Tuyết Ngân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

Exercise: Exercise 1: Calculate The Price TTC of An Item From Its Price HT, With A Rate of VAT To 19.6%

The document contains 22 math exercises involving calculating prices with tax, converting times to hours/minutes/seconds, calculating sequences, plotting functions, finding greatest common divisors, prime numbers, and more. The exercises provide algorithms and Scilab code to perform the calculations and demonstrate how to write functions to solve similar problems.

Uploaded by

Tuyết Ngân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXERCISE

Exercise 1: Calculate the price TTC of an item from its price HT, with a rate of VAT to 19.6%.

Algorithm

- Read the price without VAT and put it in HT


- Calculate price with taxes and put it in TTC
- Display TTC

Solution:
Calculation and simple display
-->HT=540;
-->TTC=HT*1.196
TTC =
645.84

Value request and formatted display:


-->HT=input("Price without tax : ");
Price without tax : 3789
-->TTC=HT*1.196;
-->disp("The price with taxes is"+string(TTC))
The price with taxes is 4531.644

Function:
-->function TTC=f(HT);
-->TTC=HT*1.196;
-->endfunction
-->f(540)
ans =
645.84
-->f(3789)
ans =
4531.644

Exercise 2: Convert a given time into seconds, hours, minutes and seconds.

Algorithm
- Read the time in seconds, put it in t
- Put q in quotient of t by 60 (number of minutes)
- Put in s the remainder (number of seconds)
- Put in h the quotient of q by 60 (number of hours)
- Put in m the remainder (minutes remaining)
- Display hours, minutes, seconds

Scilab code
Calculation and simple display:
t = 12680;
q = floor(t/60);
s = t-60*q;
h = floor(q/60);
m = q-60*h;
disp([h,m,s])

Value request and formatted display:


t=input("Time in seconds : ");
q=floor(t/60);
s = t-60*q;
h = floor(q/60);
m = q-60*h;
disp(string(h)+" hours "+string(m)+" minutes "+ string(s)+" seconds ")

Function
function y=f(t)
q = floor(t/60);
s = t-60*q;
h = floor(q/60);
m = q-60*h;
y=[h,m,s]
endfunction
disp(f(12680))

Exercise 3: Calculate the hypotenuse of a triangle knowing the two sides of the right angle.

Exercise 4: Calculate the squares of the natural integers from 1 to 100 and store the results
in a vector c. Display the value of c(37).

Exercise 5: Calculate the first 30 terms of the sequence defined by:


u1= 1, un+1= un +2n+3, n = 1,2…

Display the index and the values of the calculated sequence, and then plotting them.

Exercise 6: Calculate the quotient q in the division of a positive number n by 11, by the
method of successive subtractions.

Exercise 7: Bob placed € 5,000 in compound interest with a rate of 2.7% per year in 2009.
- Calculate the amounts obtained for the next 20 years,
- Draw a graph depicting the total amount obtained annually,
- Write a program to find the year that Bob will get € 7,000.

Exercise 8: Calculate the first 40 terms of the sequence defined by:


 2a + b
 an +1 = n n
 1
a = 20  4
 ;  ; n  1.
 b1 = 60  b = an + 2bn
 n +1 4
Then calculate the element of the sequence {un} and {vn} defined by:
u n = a n + bn , vn = a n - bn , n  1.
Display the obtained results.
Exercise 9: Given two sequences {un} and {vn} defined by
1 1 1 1 1 1
u n = 1+ + +...+ − ln(n); v n = 1+ + +...+ − ln(n + 1), n  1.
2 3 n 2 3 n
Calculate the first 200 elements of each array and find out from which position the
difference between the two sequences is less than 0.01, and then give the value of u and v
at that position.

Exercise 10: Find an approximate value of the golden ratio, the positive solution of the
following equation
x2 = x + 1
as follows
1) Define the function f(x) = x 2 - x - 1.
2) Plot the graph of this function on the interval [-5, 5]
3) Write a program allowing, by dichotomy method, to frame the desired solution in a
range of amplitude 10^- 4 starting from the values 1 and 2.

Exercise 11: The Syracuse sequence is defined by: u1 is given and for n  1,
 un
 if u n even
u n+1 =  2
3u n + 1 otherwise.
Calculate the terms and verify that, whatever u1, we always arrive at 4, 2, 1. To do this, one
defines the Syracuse function which will give, according to the first term, the rank at which
one arrives at 1 and all term of that sequence.
(http://en.wikipedia.org/wiki/Collatz_conjecture)

Exercise 12: Plotting the graphs:


a) The graph of cube function y = x 3 on [-2, 2] ;

( )
b) The graph of function y = f(x) = x + ln x - 1 on [1, 5]; and it is red.
2x + 3

Exercise 13: Plotting the graph of functions on [0, 4]


f p (x) = p x 2 +9 + 4 - x
with p = 2, and with p varying from 1 to 2 by step 0.1.

Exercise 14: Plotting the graph of function defined by


0 if x  [0, 2)

f(x) =  x - 2 if x  [2, 4)
2x - 3 if x  [4, 7)

Exercise 15: Plot the graph of function z = 4xy2 + x + 3y , for x in [-10, 10], y in [-5, 5]

Exercise 16: Write a program that calculates the coefficients of the Newtonian binomial
expansion (that is Cnk, k=1,…,n) with n = 1,2, ..., 10, and display as a table (Pascal's triangle).
Exercise 17: Write a program to create a function divide that computes the quotient and
the remainder in the division of a by b, where a and b are two positive integers. Use this
function to calculate the quotient and the remainder in the division of 1224 by 15.

Exercise 18: Write a prem function that checks whether a given integer is prime number or
not? Use this function to verify the integer a = 232 + 1 is prime?

Exercise 19: Prime decomposition of an integer: Write a function decomp to decompose a


given a positive integer into primes. This function will give the result is a sequence of all
prime divisors of this integer number (can be repeated if there are multiple). Use this
function to decompose the positive integer a = 4560 into prime number.

Exercise 20: Create a UCLN function to find the greatest common divisor of given two
integers a, b. Use this function to calculate the greatest common divisor of two numbers
595 and 10200.

Exercise 21: Create a BEZOUT function to find the Bézout coefficients of given two positive
numbers a and b, that are integer numbers u and v such that au + bv = UCLN(a, b). Use this
function to find the Bézout coefficients of 595 and 10200.

Exercise 22: Mersenne numbers are formed by the formula n = 2p - 1, where p is a prime
number. Write a program to determine which Mersenne number is prime, for p < 40.

You might also like