Sailors, coconuts and a monkey problem: Difference between revisions
Sailors, coconuts and a monkey problem (view source)
Revision as of 21:45, 26 June 2021
, 2 years agoSailors, coconuts and a monkey problem en FreeBASIC
m (→JS ES6: (Tidied)) |
(Sailors, coconuts and a monkey problem en FreeBASIC) |
||
Line 664:
8: 117440505 5044200
9: 387420481 14913080 ok</pre>
=={{header|FreeBASIC}}==
{{trans|Yabasic}}
<lang freebasic>
Dim As Integer cocos = 11
For ns As Integer = 2 To 9
Dim As Integer oculta(ns)
cocos = Int(cocos / ns) * ns + 1
Do
Dim As Integer nc = cocos
For s As Integer = 1 To ns+1
If nc Mod ns = 1 Then
oculta(s-1) = Int(nc / ns)
nc = nc - (oculta(s-1) + 1)
If s = ns And Not (nc Mod ns) Then
Print ns; " marineros requieren un m¡nimo de"; cocos; " cocos"
For t As Integer = 1 To ns
Print !"\tEl marinero"; t; " se esconde"; oculta(t - 1)
Next t
Print !"\tEl mono obtiene"; ns
Print !"\tFinalmente, cada marinero se lleva"; Int(nc / ns); !"\n"
Exit Do
End If
Else
Exit For
End If
Next s
cocos += ns
Loop
Next ns
Sleep
</lang>
=={{header|Go}}==
|