Financing Plan on Planet XY140Z-n
Description:
I need to save some money to buy a gift. I think I can do something like that:
First week (W0) I save nothing on Sunday, 1 on Monday, 2 on Tuesday... 6 on Saturday, second week (W1) 2 on Monday... 7 on Saturday and so on according to the table below where the days are numbered from 0 to 6.
Can you tell me how much I will have for my gift on Saturday evening after I have saved 12? (Your function finance(6) should return 168 which is the sum of the savings in the table).
Imagine now that we live on planet XY140Z-n where the days of the week are numbered from 0 to n (integer n > 0) and where I save from week number 0 to week number n included (in the table below n = 6).
How much money would I have at the end of my financing plan on planet XY140Z-n?
-- | Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|---|
W6 | 12 | ||||||
W5 | 10 | 11 | |||||
W4 | 8 | 9 | 10 | ||||
W3 | 6 | 7 | 8 | 9 | |||
W2 | 4 | 5 | 6 | 7 | 8 | ||
W1 | 2 | 3 | 4 | 5 | 6 | 7 | |
W0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
Example:
finance(5) --> 105
finance(6) --> 168
finance(7) --> 252
finance(5000) --> 62537505000
Note:
your solution will be nicer without loops.
Similar Kata:
Stats:
Created | Jul 8, 2015 |
Published | Jul 8, 2015 |
Warriors Trained | 14930 |
Total Skips | 4000 |
Total Code Submissions | 16941 |
Total Times Completed | 4886 |
Ruby Completions | 129 |
Python Completions | 869 |
Haskell Completions | 85 |
Java Completions | 852 |
Clojure Completions | 67 |
JavaScript Completions | 600 |
CoffeeScript Completions | 25 |
C# Completions | 349 |
TypeScript Completions | 99 |
C++ Completions | 555 |
Elixir Completions | 95 |
PHP Completions | 214 |
Crystal Completions | 17 |
F# Completions | 45 |
C Completions | 453 |
Rust Completions | 164 |
Swift Completions | 138 |
Go Completions | 247 |
Nim Completions | 22 |
R Completions | 73 |
Shell Completions | 42 |
OCaml Completions | 41 |
Fortran Completions | 23 |
Julia Completions | 29 |
Scala Completions | 43 |
PowerShell Completions | 25 |
Reason Completions | 5 |
Racket Completions | 27 |
Forth Completions | 20 |
Factor Completions | 17 |
Kotlin Completions | 49 |
Prolog Completions | 16 |
Pascal Completions | 13 |
Raku Completions | 9 |
Perl Completions | 12 |
COBOL Completions | 13 |
Elm Completions | 10 |
D Completions | 9 |
Erlang Completions | 12 |
Total Stars | 235 |
% of votes with a positive feedback rating | 83% of 767 |
Total "Very Satisfied" Votes | 560 |
Total "Somewhat Satisfied" Votes | 156 |
Total "Not Satisfied" Votes | 51 |