Statistics

Problem Statement for "JoshSum"

Problem Statement

Josh thought he would be cooler if he had his own secret sum. The Josh Sum of an integer n is the sum of the last digit of each of the first n terms of the Fibonacci series. The Fibonacci series is : 1,1,2,3,5,etc. The i-th term of the series is equal to the sum of the (i-1)-th term and (i-2)-th term, and the first and second terms are 1. The Josh Sum for n = 7 is 1 + 1 + 2 + 3 + 5 + 8 + 3 = 23. Given n, return its Josh Sum.

Definition

Class:
JoshSum
Method:
getJoshSum
Parameters:
int
Returns:
int
Method signature:
int getJoshSum(int n)
(be sure your method is public)

Constraints

  • n will be between 1 and 100000, inclusive.

Examples

  1. 7

    Returns: 23

    The first 7 Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13; therefore the answer is 1 + 1 + 2 + 3 + 5 + 8 + 3 = 23.

  2. 1

    Returns: 1

    The first Fibonacci number is 1. The answer is 1.

  3. 365

    Returns: 1692

  4. 44

    Returns: 212

  5. 98765

    Returns: 460892

  6. 1

    Returns: 1

  7. 2

    Returns: 2

  8. 100000

    Returns: 466675

  9. 5005

    Returns: 23347

  10. 50007

    Returns: 233358

  11. 75009

    Returns: 350028

  12. 133

    Returns: 609

  13. 2076

    Returns: 9688

  14. 20098

    Returns: 93799

  15. 10876

    Returns: 50743

  16. 80908

    Returns: 377559

  17. 99999

    Returns: 466670

  18. 98789

    Returns: 461008

  19. 67876

    Returns: 316743

  20. 3

    Returns: 4

  21. 4

    Returns: 7

  22. 5

    Returns: 12

  23. 99960

    Returns: 466480

  24. 99961

    Returns: 466481

  25. 99959

    Returns: 466480


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: