5 kyu
Perimeter of squares in a rectangle
15,214 of 43,632g964
Description:
The drawing shows 6 squares the sides of which have a length of 1, 1, 2, 3, 5, 8.
It's easy to see that the sum of the perimeters of these squares is :
4 * (1 + 1 + 2 + 3 + 5 + 8) = 4 * 20 = 80
Could you give the sum of the perimeters of all the squares in a rectangle when there are n + 1 squares disposed in the same manner as in the drawing:
Hint:
See Fibonacci sequence
Ref:
The function perimeter has for parameter n where n + 1 is the number of squares (they are numbered from 0 to n) and returns the total perimeter of all the squares.
perimeter(5) should return 80
perimeter(7) should return 216
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Jul 6, 2015 |
Published | Jul 6, 2015 |
Warriors Trained | 88013 |
Total Skips | 19815 |
Total Code Submissions | 142951 |
Total Times Completed | 43632 |
Ruby Completions | 1024 |
Python Completions | 15214 |
Haskell Completions | 665 |
Clojure Completions | 173 |
Java Completions | 4248 |
C# Completions | 2522 |
CoffeeScript Completions | 24 |
JavaScript Completions | 8850 |
C++ Completions | 3389 |
PHP Completions | 1370 |
Crystal Completions | 23 |
F# Completions | 106 |
C Completions | 1799 |
TypeScript Completions | 1359 |
Rust Completions | 955 |
Swift Completions | 459 |
Go Completions | 1092 |
R Completions | 125 |
Shell Completions | 66 |
Objective-C Completions | 30 |
OCaml Completions | 25 |
Fortran Completions | 18 |
Elixir Completions | 151 |
Julia Completions | 60 |
Scala Completions | 234 |
PowerShell Completions | 47 |
Nim Completions | 19 |
Racket Completions | 46 |
Reason Completions | 5 |
Forth Completions | 27 |
Kotlin Completions | 411 |
Prolog Completions | 21 |
Dart Completions | 282 |
Pascal Completions | 15 |
Raku Completions | 11 |
Lua Completions | 116 |
Perl Completions | 18 |
Elm Completions | 8 |
COBOL Completions | 12 |
D Completions | 8 |
Erlang Completions | 10 |
NASM Completions | 23 |
Total Stars | 1103 |
% of votes with a positive feedback rating | 86% of 3687 |
Total "Very Satisfied" Votes | 2820 |
Total "Somewhat Satisfied" Votes | 734 |
Total "Not Satisfied" Votes | 133 |