Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
Why not Simply use array as this value is getting doubled each time just loop through the index of array and doubles the value each time Here is java solution👉 int bacteria=500; int hours[ ]=new int[10]; for(int i=0;i<arr.length;i++){ hours[i]=bacteria; bacteria*=2; } It will assign - arr[0]=500 arr[1]=1000 arr[2]=2000 and so on..
17th Sep 2021, 5:25 PM
Patel
0
bacteria = 500 passed_hours = 3 for i in range(1, passed_hours+1): bacteria *= 2 print(f"Bacteria after {i} hours : {bacteria}")
17th Sep 2021, 5:33 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
# I hope this will help # This method is way more efficient then brute forcing bacteria = 500 passed_hours = 6 bacteria = bacteria * (2**passed_hours) print(f"Bacteria after {passed_hours} hours : {bacteria}")
17th Sep 2021, 5:58 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
I'm still learning python sir, after python I'll move to java.
17th Sep 2021, 11:48 PM
Patrick Fernandez
0
bact=500 hr=10 for i in range(1,hr+1): bact *=2 print(f"The number of bacteria after {i} hr is {bact}")
18th Sep 2021, 12:28 AM
Joseph Edet
Joseph Edet - avatar
0
Starts=500 Hours=24 Bacteriaafter1day=(Starts*(2**Hours)) print (Bacteriaafter1day)
18th Sep 2021, 2:19 AM
Shreesaraan D
Shreesaraan D - avatar
0
Qui peut m'apprendre python svp
18th Sep 2021, 8:00 PM
Dietrich
Dietrich - avatar
0
Patrick Fernandez It seems your question appears to be an assignment. Please show us your attempt and use the 8 rules to get help from the community. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community *can be a code coach solution which is meant for you to do to help you establish your skills abilities and where you need to learn... not the community *one issued by a school or other institution *one issued or created by another platform *one that appears to be in the form of a challenge that was created by you or somewhere else. Your question has been reviewed and will be marked for deletion. https://www.sololearn.com/Discuss/1316935/?ref=app
19th Sep 2021, 2:36 AM
BroFar
BroFar - avatar
- 1
Sir how about python?
17th Sep 2021, 11:48 PM
Patrick Fernandez