Magic is simple (for beginners)
Determine for a magic square of order n, the magic sum m. For example m=15 for a magic square of order 3.
27日 前
解決済み
Differential equations I
Given a function handle |f| an initial condition |y0| and a final time |tf|, solve numerically the differential equation
dy...
27日 前
解決済み
Fibonacci sequence
Calculate the nth Fibonacci number.
Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...
Examples:
Input...
27日 前
解決済み
Reverse the vector
Reverse the vector elements.
Example:
Input x = [1,2,3,4,5,6,7,8,9]
Output y = [9,8,7,6,5,4,3,2,1]
27日 前
解決済み
Roll the Dice!
Description
Return two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.
Example
[x1,x2] = rollDice(...
27日 前
解決済み
Sum all integers from 1 to 2^n
Given the number x, y must be the summation of all integers from 1 to 2^x. For instance if x=2 then y must be 1+2+3+4=10.
27日 前
解決済み
Sum of series I
What is the sum of the following sequence:
Σ(2k-1) for k=1...n
for different n?
27日 前
解決済み
Pi Estimate 1
Estimate Pi as described in the following link:
<http://www.people.virginia.edu/~teh1m/cody/Pi_estimation1.pdf>
27日 前
解決済み
Approximation of Pi
Pi (divided by 4) can be approximated by the following infinite series:
pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...
For a given number of...
Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...
Flip the vector from right to left
Flip the vector from right to left.
Examples
x=[1:5], then y=[5 4 3 2 1]
x=[1 4 6], then y=[6 4 1];
Request not to use d...
Vector creation
Create a vector using square brackets going from 1 to the given value x in steps on 1.
Hint: use increment.
約1ヶ月 前
解決済み
Create a vector
Create a vector from 0 to n by intervals of 2.
約1ヶ月 前
解決済み
Find max
Find the maximum value of a given vector or matrix.
約1ヶ月 前
解決済み
Find the Best Hotels
Given three input variables:
hotels - a list of hotel names
ratings - their ratings in a city
cutoff - the rating at which yo...
約1ヶ月 前
解決済み
Calculate BMI
Given a matrix hw (height and weight) with two columns, calculate BMI using these formulas:
1 kilogram = 2.2 pounds
1 inch = 2...
約1ヶ月 前
解決済み
Find the Oldest Person in a Room
Given two input vectors:
* |name| - user last names
* |age| - corresponding age of the person
Return the name of the ol...