Integer roots: Difference between revisions
Content added Content deleted
(→{{header|Raku}}: simplifying with the sequence operator) |
No edit summary |
||
Line 386: | Line 386: | ||
3 |
3 |
||
1414213562</pre> |
1414213562</pre> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
local fn root( n as UInt64, x as UInt64 ) as double |
|||
double nr, result = 0 |
|||
for nr = fn floor( sqr(x) ) to 1 step -1 |
|||
if ( nr ^ n ) <= x then result = nr : exit fn |
|||
next |
|||
end fn = result |
|||
print @"3rd root of 8 = "; fn root( 3, 8 ) |
|||
print @"3rd root of 9 = "; fn root( 3, 9 ) |
|||
print @"4th root of 167 = "; fn root( 4, 167 ) |
|||
print @"2nd root of 2e+018 = "; fn root( 2, 2e+018 ) |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre> |
|||
3rd root of 8 = 2 |
|||
3rd root of 9 = 2 |
|||
4th root of 167 = 3 |
|||
2nd root of 2e+018 = 1414213562 |
|||
</pre> |
|||