We needed to create a program that asks the user for two pieces of data:
- The lower bound of the sequence
- The upper bound of the sequence
This page helped also. https://mattmccutchen.net/bigint/
Here’s my code in GitHub.
Fundamentals and Solutions. Together!
We needed to create a program that asks the user for two pieces of data:
Here’s my code in GitHub.
We created a function called euler_calc with a single parameter precision. The value of precision is used to determine when to stop calculating. Your calculation will stop when the two consecutive values estimating e differ by less than precision. For example:
In this code, you’ll need also another function for a factorial because de euler number has this formula:
so it is 1/factorial with a limit until when the two consecutive values estimating e differ by less than precision. And the precision will be as short or long as you want.
If you calculate the e number on a scientific calculator, the number will be 2.718281828.
First you write the euler function like this euler_cacl (float precision) , with the 2 floats variables, e for the answer, prev for the previous e value; and 1 int = n. Then there’s the loop Do While, and will do e = e / (1/factorial(n)).
The factorial function must be like this, because you can’t have 0* n, because it will return you 0, and you can’t have a 0 as a divisor.
For the While in the euler function, must be while ((e-prev)>precision). The the loop will stop and you will have the answer which is “e”.
Here’s my GitHub link.
https://github.com/antonioangelm24/TC101/blob/master/Quiz%204
This quiz took me a while, not only because I finished it on last class, but I haven’t had time in the partials week.
Anyway, the first quiz was kind of easy because you only needed to follow the formula of the distance of two points in the plane.
So I look up in google for the formula and I found this one on http://www.elosiodelosantos.com/sergiman/div/formula_dos_puntos.htm
and the formula was and I just create the function of the program based on the formula.
Also, I needed to include the cmath library, in order to be able to use “sqrt” that is the square root. One of my classmates told me that.
The link of my github account on this code is at the end.
For the second exercise, we needed to create a program which can tell you the value of a location in the fibonacci’s serie.
Honestly at the beginning I was so frustrated because I have no idea how to do it. I look up to the formula but i was this one: , and I didn’t understand it. So my friend Miguel gave me a hand. Told to put those 4 integers to use them on my code. Finally with his help we could create this code and I worked. You should see my face at the moment.
The link to my GitHub account is right here.
https://github.com/antonioangelm24/TC101/blob/master/Quiz%203%20_%202%20-%20Fibonacci
https://github.com/antonioangelm24/TC101/blob/master/Quiz%203_1
This program should give you the same results as the WSQ03 but using function for each operation.
So basically, I write single functions, to the sum, product, difference, and division operations. Using void instead of int. And this was kind of quickly because I just copy the main code from de WSQ03, and then I started to editing what I needed.
Here’s the link to my GitHub.
This program should give you the sum of a specific range, that you will provide to the computer. So if you type 3 & 9, the program should return the sum of 3+4+5+6+7+8+9.
So..
First you need to call the two integers of the range, also the result.
I did one work like this when I was in computing remedial.
In this case y & x are the range and x the result.
You keep adding +1 every time until y = z, then you stop.
The link to my GitHub is here too..
https://github.com/antonioangelm24/TC101/blob/master/WSQ07