小编Ram*_*day的帖子

将JSON数据存储到变量中

我是AngularJS的新手.我只想将JSON文件数据加载到位于工厂中的变量中.

myApp.factory('quizFactory', function () {
    var questions = [
        {
            "setId":1,
            "question":"What is the value of the 7 in the following number? 850,765",
            "options": ["70", "7", "7000", "700"],
            "answer": 3
        },
        {
            "setId":2,
            "question":"Is 7 & 9 even or odd?",
            "options": ["Even", "Odd", "Can't Say", "Dont know"],
            "answer": 1
        },
        {
            "setId":3,
            "question":"In the number 5,281,946 what is the value of the 3rd place?",
            "options": ["100", "10,000", "1,000,000", "1,000"],
            "answer": 0 
        },
        {
            "setId":4,
            "question":"Is 12 + 50 even or …
Run Code Online (Sandbox Code Playgroud)

json factory angularjs

5
推荐指数
1
解决办法
9445
查看次数

2 个斐波那契数的乘积

我的任务:

给定一个数字,比如说 prod(对于产品),我们搜索两个斐波那契数 F(n) 和 F(n+1) 验证

F(n) * F(n+1) = prod if F(n) * F(n+1) = prod
Run Code Online (Sandbox Code Playgroud)

您的函数 productFib 接受一个整数 (prod) 并返回一个数组:

[F(n), F(n+1), True] else 
Run Code Online (Sandbox Code Playgroud)

F(m) 是最小的,例如 F(m) * F(m+1) > prod

[F(m), F(m+1), False] 
Run Code Online (Sandbox Code Playgroud)

例子:

productFib(714) # should return [21, 34, True], 
            # since F(8) = 21, F(9) = 34 and 714 = 21 * 34

productFib(800) # should return [34, 55, False], 
            # since F(8) = 21, F(9) = 34, F(10) = 55 and 21 * …
Run Code Online (Sandbox Code Playgroud)

python function fibonacci python-3.x

0
推荐指数
1
解决办法
1577
查看次数

标签 统计

angularjs ×1

factory ×1

fibonacci ×1

function ×1

json ×1

python ×1

python-3.x ×1