+ 18

# CHALLENGE : NUMBER OF DOTS 💻⌨️🖱️

Find how many dots exist in a pentagonal shape around a center dot on the Nth iteration. For example, on the first iteration there is a single dot, on the second there are 6 dots, on the third there are 16 dots, etc. First : ▪️ Second : ▪️ ▪️▪️▪️ ▪️▪️ Third : ▪️ ▪️ ▪️ ▪️ ▪️ ▪️▪️▪️ ▪️ ▪️ ▪️▪️ ▪️ ▪️▪️▪️ Your code receive positive integer N as number of iteration, and return the number of dots that exist in the whole pentagon on Nth iteration.

14th Dec 2017, 11:46 AM
LukArToDo
15 ответов
14th Dec 2017, 11:55 AM
#RahulVerma
14th Dec 2017, 6:34 PM
Gaurav Agrawal
+ 15
14th Dec 2017, 12:57 PM
LukArToDo
+ 13
https://code.sololearn.com/ctR2zK5uMuuq/?ref=app
14th Dec 2017, 1:26 PM
Käzî Mrîdùl Høssäîn
14th Dec 2017, 2:27 PM
qwerty
+ 12
14th Dec 2017, 12:02 PM
Krishna Teja Yeluripati
14th Dec 2017, 2:35 PM
Justine Ogaraku
+ 8
@Zandifer Your code gives the number of dots in one (last) iteration. Need to find the number of dots in the whole pentagram (in N iterations).
14th Dec 2017, 12:27 PM
LukArToDo
14th Dec 2017, 12:28 PM
David Akhihiero
14th Dec 2017, 3:38 PM
Ferhat Sevim
+ 5
https://code.sololearn.com/cAifJ12KlayB/?ref=app
14th Dec 2017, 1:17 PM
...
+ 5
I decided to complete this challenge using ALL languages supported in SoloLearn. The code was simplified and so only works with possitive integer inputs (1, 2, 3, ...). As far as I understood, PHP in SoloLearn doesn't support I/O, so I omitted it. Original (works with many input types): https://code.sololearn.com/WP6w8F6pV277/?ref=app Simplified and unified (works with positive integer inputs only): https://code.sololearn.com/cCaNP4VrOlJx/?ref=app https://code.sololearn.com/cPvVSSSUZP0s/?ref=app https://code.sololearn.com/cl57a9pm62r5/?ref=app https://code.sololearn.com/cnEERHz4tO8h/?ref=app https://code.sololearn.com/cvmPWfwJS0ts/?ref=app https://code.sololearn.com/WcKpJ2z2HPvq/?ref=app
14th Dec 2017, 5:17 PM
Augustinas Lukauskas
14th Dec 2017, 12:23 PM
Zandifier
+ 4
@LukArToDo it is fixed
14th Dec 2017, 12:35 PM
Zandifier
14th Dec 2017, 3:37 PM
Augustinas Lukauskas
Актуальное сегодня
super laggy