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:
Inpu...
3年以上 前
解決済み
Calculate Amount of Cake Frosting
Given two input variables r and h, which stand for the radius and height of a cake, calculate the surface area of the cake you n...
3年以上 前
解決済み
Doubling elements in a vector
Given the vector A, return B in which all numbers in A are doubling. So for:
A = [ 1 5 8 ]
then
B = [ 1 1 5 ...
Vector creation
Create a vector using square brackets going from 1 to the given value x in steps on 1.
Hint: use increment.
3年以上 前
解決済み
Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.
Example...
3年以上 前
解決済み
Generate a vector like 1,2,2,3,3,3,4,4,4,4
Generate a vector like 1,2,2,3,3,3,4,4,4,4
So if n = 3, then return
[1 2 2 3 3 3]
And if n = 5, then return
[1 2 2 3 3 3 4...
3年以上 前
解決済み
Check if number exists in vector
Return 1 if number _a_ exists in vector _b_ otherwise return 0.
a = 3;
b = [1,2,4];
Returns 0.
a = 3;
b = [1,...
Getting the indices from a vector
This is a basic MATLAB operation. It is for instructional purposes.
---
You may already know how to <http://www.mathworks....
Number of 1s in a binary string
Find the number of 1s in the given binary string.
Example. If the input string is '1100101', the output is 4. If the input stri...