To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

fib.py 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

John Zhang's avatar
John Zhang committed
16
def fib(n):
John Zhang's avatar
John Zhang committed
17
    if n in (0, 1):
John Zhang's avatar
John Zhang committed
18
        return 1
John Zhang's avatar
John Zhang committed
19
    return fib(n - 1) + fib(n - 2)
John Zhang's avatar
John Zhang committed
20

Zixian Cai's avatar
PEP 8    
Zixian Cai committed
21

22
def main(argv):
John Zhang's avatar
John Zhang committed
23
    from callback import get_callback
John Zhang's avatar
John Zhang committed
24
25
    libcb_path, cb_param = argv[1:3]
    cb = get_callback(libcb_path)(cb_param)
26

John Zhang's avatar
John Zhang committed
27
    scale_factor = int(argv[3])
28
    n = int(argv[4])
John Zhang's avatar
John Zhang committed
29

John Zhang's avatar
John Zhang committed
30
31
32
33
34
    s = 0
    cb.begin()
    for i in range(scale_factor):
        s += fib(n)
    cb.end()
35
    cb.report()
John Zhang's avatar
John Zhang committed
36
    return s != fib(n) * scale_factor
John Zhang's avatar
John Zhang committed
37

Zixian Cai's avatar
PEP 8    
Zixian Cai committed
38

John Zhang's avatar
John Zhang committed
39
40
if __name__ == '__main__':
    import sys
John Zhang's avatar
John Zhang committed
41
    sys.exit(main(sys.argv))