0

Can you help me in practice 15.2 golang?

I can not understand how l can do it with "for"?

19th Jan 2022, 7:47 PM
Oll 25
6 Respuestas
+ 1
package main import "fmt" func main() { var years int fmt.Scanln(&years) //your code goes here r:=7 for i:=1;i<=years; i++ { r*=2 if i == years { fmt.Println(r)} }}
20th Jan 2022, 10:02 AM
Oll 25
0
You have to make a loop that runs "years" times, doubling the number of rabbits each time.
19th Jan 2022, 8:33 PM
CGM
CGM - avatar
0
Thank you, I understood that I must write loop, but I can't understand logically how I must do it, I during the days read task and lessons)
19th Jan 2022, 8:42 PM
Oll 25
0
From lessons I can't understand how l can doubling number
19th Jan 2022, 9:02 PM
Oll 25
0
This is how you duplicate it Num*=2 And in the "for" you have to change the condition to be executed while the iterator variable (commonly called "i") is less than "the expected number of iterations"
19th Jan 2022, 9:13 PM
CGM
CGM - avatar
0
Ok, thank you so much, I will try it tomorrow because my brain is going today explain) ( I was trying num*=2,but.,.)
19th Jan 2022, 9:22 PM
Oll 25