A question on go, your age in mars | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

A question on go, your age in mars

Has any of you solved that age on mars thing in go. I have tried so many ways to go about it, but I am still getting stuck

14th Mar 2022, 9:10 AM
Chibuzo Franklin Odigbo
Chibuzo Franklin Odigbo - avatar
7 Answers
+ 4
Chibuzo Odigbo Here in your code you will have to multiply the age on earth by 365 to get the age in days on earth, then you have to divide it by 687 to get the age on mars. Hope it helps. Happy coding 🤠
14th Mar 2022, 9:32 AM
Adil
Adil - avatar
+ 3
I've done that but first show your trial code so that we can help.
14th Mar 2022, 9:11 AM
Adil
Adil - avatar
+ 3
Chibuzo Odigbo I didn't like Go, but I have also completed this challenge also. As Adil has stated, please show your attempt so we may guide you to a solution
14th Mar 2022, 9:19 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Chibuzo Odigbo Yes. Here is the code I did: package main import "fmt" func main() { var age int fmt.Scanln(&age) age*=365 age/=687 fmt.Println(age) }
14th Mar 2022, 9:36 AM
Adil
Adil - avatar
+ 2
This will work great package main import "fmt" var age int func mars_age(age int)int{ fmt.Scanln(&age) return (age * 365)/687 } func main(){ result := mars_age(age) fmt.Println(result) }
25th Mar 2022, 11:47 AM
Mahdi Bahadori
Mahdi Bahadori - avatar
+ 1
package main import "fmt" func main() { var age int fmt.Scanln(&age) mars_age:=age mars := mars_age/2 fmt.Println(mars) } this is what my code looks like
14th Mar 2022, 9:24 AM
Chibuzo Franklin Odigbo
Chibuzo Franklin Odigbo - avatar
+ 1
So, basically, I'll be giving earth an integer, and then divide that integer by the mars days?
14th Mar 2022, 9:34 AM
Chibuzo Franklin Odigbo
Chibuzo Franklin Odigbo - avatar