General FizzBuzz: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 57:
{{trans|Python}}
<
V sfactorwords = sorted(factorwords, key' p -> p[0])
[String] lines
Line 65:
R lines.join("\n")
print(genfizzbuzz([(5, ‘Buzz’), (3, ‘Fizz’), (7, ‘Baxx’)], 1..20))</
{{out}}
Line 92:
=={{header|Action!}}==
<
DEFINE MAX_LEN="20"
DEFINE MAX_FACTORS="5"
Line 184:
PutE()
PrintResult(max,n,factors,texts)
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/General_FizzBuzz.png Screenshot from Atari 8-bit computer]
Line 202:
=={{header|Ada}}==
<syntaxhighlight lang="ada">
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
Line 253:
general_fizz_buzz (20, fizzy);
end Main;
</syntaxhighlight>
{{output}}
<pre>
Line 280:
=={{header|ALGOL 68}}==
Uses a modified version of the Algol 68 Quicksort task sample.
<
# prompts for an integer, reads it and returns it #
PROC read integer = ( STRING prompt )INT:
Line 356:
print( ( text, newline ) )
OD
END</
{{out}}
<pre>
Line 390:
=={{header|AppleScript}}==
<
-- fizzEtc :: [(Int, String)] -> [Symbol]
Line 516:
set my text item delimiters to dlm
s
end unlines</
{{Out}}
<pre>1
Line 541:
=={{header|Arturo}}==
<
facts: map 1..3 'x -> split.words strip input ~"Enter factor |x|: "
loop 1..maxNum 'i [
Line 551:
]
print (printNum)? -> i -> ""
]</
{{out}}
Line 581:
=={{header|AutoHotkey}}==
<
max := 20, fizz := 3, buzz := 5, baxx := 7
Line 597:
FileAppend %output%`n, *
}
</syntaxhighlight>
{{Out}}
<pre>
Line 637:
;Usage:
<
awk -f fizzbuzzCustom.awk numbers.txt</
;Program:
<!-- http://ideone.com/fACMfK -->
<!-- (!!) Note: the sandbox at ideone.com does not allow output to files -->
<
#
function Print(s) {
Line 675:
print "END {print " q2 "# Done." q2 "}"
Print( "# Done." )
}</
Example output see [[FizzBuzz/AWK#Custom_FizzBuzz]]
=={{header|Batch File}}==
<
rem input range
set /p "range=> "
Line 710:
)
pause
exit /b 0</
{{Out}}
<pre>> 20
Line 741:
=={{header|BBC BASIC}}==
This implementation (unlike some of the ones given on this page...) fully obeys the specification, in that it prompts the user for the parameters at run time. It also allows users to specify as many factors as they want, rather than limiting them to three.
<
INPUT "Maximum number: " max%
INPUT "Number of factors: " n%
Line 760:
NEXT
IF matched% THEN PRINT ELSE PRINT;i%
NEXT</
Output:
<pre>Maximum number: 20
Line 789:
=={{header|BQN}}==
<
Example usage:
<syntaxhighlight lang="text"> ⟨3‿"Fizz", 5‿"Buzz", 7‿"Baxx"⟩ GenFizzBuzz 20
⟨ 1 2 "Fizz" 4 "Buzz" "Fizz" "Baxx" 8 "Fizz" "Buzz" 11 "Fizz" 13 "Baxx" "FizzBuzz" 16 17 "Fizz" 19 "Buzz" ⟩</
=={{header|C}}==
<syntaxhighlight lang="c">
#include <stdio.h>
#include <stdlib.h>
Line 849:
return 0;
}
</syntaxhighlight>
{{out}}
<pre>
Line 876:
=={{header|C sharp}}==
Not extremely clever and doesn't use anything too fancy.
<
using System;
Line 937:
}
}
</syntaxhighlight>
=={{header|C++}}==
<
#include <algorithm>
#include <iostream>
Line 978:
return 0;
}
</syntaxhighlight>
{{out}}
<pre>
Line 1,004:
=={{header|Caché ObjectScript}}==
<
; loop until max, casting numeric to avoid errors
for i=1:1:+MAX {
Line 1,025:
} ; next value until MAX
quit</
Line 1,032:
=={{header|Ceylon}}==
<
print("enter the max value");
Line 1,071:
}
}
}</
=={{header|Clojure}}==
<
(map second pairs))
Line 1,088:
(apply str
(fix f)))))
numbers)))</
'''Usage:'''
Line 1,119:
=={{header|Common Lisp}}==
<syntaxhighlight lang="lisp">
(defun fizzbuzz (limit factor-words)
(loop for i from 1 to limit
Line 1,147:
(not (zerop (parse-integer input :junk-allowed t))))
finally (fizzbuzz (parse-integer input :junk-allowed t) (read-factors))))
</syntaxhighlight>
=={{header|Crystal}}==
<syntaxhighlight lang="crystal">
counter = 0
Line 1,201:
exit
end
</syntaxhighlight>
=={{header|D}}==
<
import std.stdio;
Line 1,252:
}
}
}</
{{out}}
Line 1,283:
=={{header|Elixir}}==
{{trans|Ruby}}
<
def fizzbuzz(input) do
[num | nwords] = String.split(input)
Line 1,301:
7 Baxx
"""
General.fizzbuzz(input)</
{{out}}
Line 1,336:
=={{header|Erlang}}==
<
%%% @doc Implementation of General FizzBuzz
%%% @see https://rosettacode.org/wiki/General_FizzBuzz
Line 1,362:
[fizzbuzz(X, Factors, []) || X <- lists:seq(1, N)]
).
</syntaxhighlight>
'''Usage:'''
<pre>
Line 1,396:
=={{header|Factor}}==
<
math.ranges prettyprint sequences splitting ;
IN: rosetta-code.general-fizzbuzz
Line 1,416:
: main ( -- ) get-input [ fizzbuzz ] with each ;
MAIN: main</
{{out}}
<pre>
Line 1,448:
Uses GForth specific words ']]' and '[['.
If your forth does not have them: Sequence ']] A B C .. [[' is equivalent with 'postpone A postpone B postpone C ..'
<
: times ( xt n -- )
BEGIN dup WHILE
Line 1,473:
\ Example:
\ 1 fb[ 3 s" fizz" ]+[ 5 s" buzz" ]+[ 7 s" dizz" ]+[ ]fb 40 times drop
</syntaxhighlight>
{{out}}
<pre>
Line 1,484:
=={{header|FreeBASIC}}==
{{trans|BBC BASIC}}
<
' compile with: fbc -s console
Line 1,542:
Print : Print "hit any key to end program"
Sleep
End</
{{out}}
<pre>Enter maximum number, if number < 1 then the program wil end 110
Line 1,572:
=={{header|Go}}==
<syntaxhighlight lang="go">
package main
Line 1,606:
}
}</
=={{header|Groovy}}==
<
(1..40).each {Integer value -> log +=(value %3 == 0) ? (value %5 == 0)? 'FIZZBUZZ\n':(value %7 == 0)? 'FIZZBAXX\n':'FIZZ\n'
:(value %5 == 0) ? (value %7 == 0)? 'BUZBAXX\n':'BUZZ\n'
Line 1,615:
:(value+'\n')}
println log
</syntaxhighlight>
<pre>
1
Line 1,661:
=={{header|Haskell}}==
<
fizz a xs
| null result = show a
Line 1,677:
mapM_ (\ x -> putStrLn $ fizz x multiples) [1..n]
where convert [x, y] = (read x, y)
</syntaxhighlight>
Or, as a function which takes a list of rules as an argument:
<
----------------- FIZZETC (USING RULE SET) ---------------
Line 1,704:
main :: IO ()
main = mapM_ putStrLn $ take 20 fizzTest
</syntaxhighlight>
{{Out}}
<pre>1
Line 1,731:
The trick here involves looking for where the factors evenly divide the counting numbers. Where no factor is relevant we use the counting number, an in the remaining cases we use the string which corresponds to the factor:
<
:
b=. * x|/1+i.y
>,&":&.>/(m#inv"_1~-.b),(*/b)#&.>1+i.y
)</
Example use:
<
1
2
Line 1,759:
Fizz
19
Buzz </
For our example, b looks like this:
<
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1</
<code>*/b</code> gives us 1s where we want numbers and 0s where we want to plug in the strings:
<
1 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0</
<code>m</code> is our strings, and #inv expands values out to match a selection. So, in our example, <code>m#inv"_1~-.b</code> looks like this:
<
│││Fizz││ │Fizz│ ││Fizz│ ││Fizz││ │Fizz│││Fizz││ │
├┼┼────┼┼────┼────┼────┼┼────┼────┼┼────┼┼────┼────┼┼┼────┼┼────┤
Line 1,780:
├┼┼────┼┼────┼────┼────┼┼────┼────┼┼────┼┼────┼────┼┼┼────┼┼────┤
│││ ││ │ │Baxx││ │ ││ ││Baxx│ │││ ││ │
└┴┴────┴┴────┴────┴────┴┴────┴────┴┴────┴┴────┴────┴┴┴────┴┴────┘</
All that remains is to assemble these pieces into the final result...
=={{header|Java}}==
<
public static void main(String[] args) {
Line 1,813:
}
}</
Line 1,826:
First as compacted by Google's Closure compiler:
<
return function b(a) {
return a ? b(a - 1).concat(a) : [];
Line 1,834:
}, "") || a.toString()) + "\n";
}, "");
}</
and then in the original expanded form, for better legibility:
<
return (
Line 1,863:
}
fizz([[3, 'Fizz'], [5, 'Buzz'], [7, 'Baxx']], 20);</
{{out}}
Line 1,890:
===ES6===
<
const range = (min, max) =>
Array.from({ length: max - min }, (_, i) => min + i)
Line 1,908:
).join('\n')
console.log(fizzBuzz(20))</
{{Out}}
Line 1,936:
=={{header|Julia}}==
For simplicity, assume that the user will enter valid input.
<
for i = 1 : upper
triggered = false
Line 1,964:
println("EOF\n")
fizzbuzz(triggers, upper)</
{{out}}
Line 1,998:
=={{header|Kotlin}}==
<
//Read the maximum number, set to 0 if it couldn't be read
Line 2,025:
println(i)
}
}</
=={{header|LiveCode}}==
<
put f1 & cr & f2 & cr & f3 into factors
sort factors ascending numeric
Line 2,049:
end repeat
return fizzbuzz
end generalisedFizzBuzz</
=={{header|Lua}}==
<
local response
print("\n")
Line 2,071:
param.factor[i], param.word[i] = io.read("*number", "*line")
end
genFizz(param)</
=== Without modulo ===
{{trans|Python}}
<
local res = {}
Line 2,110:
print(fizzbuzz(n, mods))
end
</syntaxhighlight>
{{out}}
Line 2,130:
===Fast Version without Modulo===
<
local num = arg[1] or tonumber(arg[1]) or 110
Line 2,160:
io.write(", ")
end
</syntaxhighlight>
{{out}}
<pre>
Line 2,168:
=={{header|Maple}}==
<
local i;
i := 1:
Line 2,199:
if (not factored) then printf("%d", i): end if:
printf("\n");
end do:</
{{Out|Output}}
<pre>1
Line 2,223:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
runTo=(*LCM@@list[[All,1]]+1*)20;
Column@Table[
Select[list,Mod[x,#[[1]]]==0&][[All,2]]/.{}->{x}
,{x,1,runTo}
]</
<pre>1
Line 2,255:
This implementation improves slightly over the proposed task, making the prompts a little friendlier.
<
maxNr = val(input("Max number? "))
Line 2,278:
end for
if matchingWords then print matchingWords else print nr
end for</
Sample session:
Line 2,308:
=={{header|Modula-2}}==
<
FROM Conversions IMPORT StrToInt;
FROM FormatString IMPORT FormatString;
Line 2,410:
ReadChar
END GeneralFizzBuzz.</
=={{header|Nanoquery}}==
{{trans|Ursa}}
<
words = {}
Line 2,447:
end
println
end</
{{out}}
Line 2,478:
=={{header|Nim}}==
This solution has no input validation
<
import parseutils, strutils, algorithm
Line 2,524:
</syntaxhighlight>
=={{header|OCaml}}==
Original version by [http://rosettacode.org/wiki/User:Vanyamil User:Vanyamil]
<syntaxhighlight lang="ocaml">
(* Task : General_FizzBuzz *)
Line 2,561:
gen_fizz_buzz 20 [(3, "Fizz"); (5, "Buzz"); (7, "Baxx")] ;;
</syntaxhighlight>
{{out}}
<pre>
Line 2,589:
{{works with|PARI/GP|2.8.0+}}
This version uses a variadic argument to allow more or less than 3 factors. It could be easily modified for earlier versions, either by taking a vector rather than bare arguments (making the call <code>fizz(20,[[3,"Fizz"],[5,"Buzz"],[7,"Baxx"]])</code>) or to support exactly factors (keeping the call the same).
<
{
v=vecsort(v,1);
Line 2,603:
);
}
fizz(20,[3,"Fizz"],[5,"Buzz"],[7,"Baxx"])</
{{out}}
<pre>1
Line 2,627:
=={{header|Perl}}==
<
#!bin/usr/perl
use 5.020;
Line 2,679:
}
}
</syntaxhighlight>
{{out}}
Line 2,714:
=={{header|Phix}}==
<!--<
<span style="color: #008080;">procedure</span> <span style="color: #000000;">general_fizz_buzz</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">lim</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">sequence</span> <span style="color: #000000;">words</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">facts</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">lim</span> <span style="color: #008080;">do</span>
Line 2,730:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">general_fizz_buzz</span><span style="color: #0000FF;">(</span><span style="color: #000000;">20</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Fizz"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Buzz"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Baxx"</span><span style="color: #0000FF;">},</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">})</span>
<!--</
{{out}}
<pre>
Line 2,756:
=={{header|PHP}}==
<
$max = 20;
Line 2,772:
}
?></
{{out}}
<pre>1
Line 2,797:
=={{header|Picat}}==
<
print("> "),
MaxNum = read_int(),
Line 2,818:
end
end,
println([F : F in FB].join(" ")).</
Testing:
Line 2,866:
=={{header|PicoLisp}}==
<
(for A N
(prinl
Line 2,876:
A ) ) ) )
(general 20 '((3 . Fizz) (5 . Buzz) (7 . Baxx)))</
{{out}}
Line 2,901:
=={{header|PowerShell}}==
<
$data = @("3 Fizz","5 Buzz","7 Baxx")
#An array with whitespace as the delimiter
Line 2,919:
Write-HoSt $outP
}
}</
{{Out}}
<pre>PS> ./GENFB
Line 2,946:
=={{header|Prolog}}==
Assuming the user specifies as input two facts of the form:
<
factors([(3, "Fizz"), (5, "Buzz"), (7, "Baxx")]).</
A simple Prolog solution to the generalised FizzBuzz problem is as follows:
<
loop(B,B,_).
Line 2,961:
fizzbuzz(N,[(F,S)|Fs],Res) :-
fizzbuzz(N,Fs,OldRes),
( N mod F =:= 0, string_concat(S,OldRes,Res) ; Res = OldRes ).</
The program can be launched by querying the predicate
<syntaxhighlight lang
It is worth noting that
<
corresponds to basic FizzBuzz and that the proposed solution can handle an arbitrary number of factors.
Line 2,974:
===Elegant naive version===
<
# sort entries by factor
factorwords.sort(key=lambda factor_and_word: factor_and_word[0])
Line 2,984:
if __name__ == '__main__':
print(genfizzbuzz([(5, 'Buzz'), (3, 'Fizz'), (7, 'Baxx')], range(1, 21)))</
{{out}}
Line 3,009:
===One-liner using generator expressions===
<
mappings = {3: "Fizz", 5: "Buzz", 7: "Baxx"}
for i in range(1, n+1): print(''.join(word * (i % key == 0) for key, word in mappings.items()) or i)</
===Generator using counters instead of modulo===
{{works with|Python|3.x}}
<
N = 100
Line 3,051:
for line in fizzbuzz(n, mods):
print(line)
</syntaxhighlight>
===Sieve of Eratosthenes===
'''This variant uses ranges with step 3, 5, etc. Preserves order and duplicate moduli.'''
<
n = 100
Line 3,087:
print(fizzbuzz(n, mods))
</syntaxhighlight>
{{Out}}
Line 3,119:
===... solution===
The task asks that we assume 3 factors for the sake of simplicity. However, R makes the k factors case not much more complicated, so we will do that. The only major downside is that checking for malformed user input becomes so difficult that we will not bother.
<
{
args <- list(...)
Line 3,136:
}
genFizzBuzz(105, c(3, "Fizz"), c(5, "Buzz"), c(7, "Baxx"))
genFizzBuzz(105, c(5, "Buzz"), c(9, "Prax"), c(3, "Fizz"), c(7, "Baxx"))</
===Names solution===
If we deviate from the task's example of how to input parameters and instead use R's names facilities to make our (number, name) pairs, we get a much cleaner solution.
<
{
factors <- sort(namedNums)#Required by the task: We must go from least factor to greatest.
Line 3,152:
namedGenFizzBuzz(105, namedNums)
shuffledNamedNums <- c(Buzz=5, Prax=9, Fizz=3, Baxx=7)
namedGenFizzBuzz(105, shuffledNamedNums)</
=={{header|Racket}}==
{{trans|Python}}
<
(define (get-matches num factors/words)
Line 3,174:
(gen-fizzbuzz 1 21 '((3 "Fizz")
(5 "Buzz")
(7 "Baxx")))</
{{out}}
<pre>1
Line 3,198:
===Alternate Solution===
<
(require racket/match)
Line 3,214:
(void))
(fizz-buzz 20 '(3 . "Fizz") '(5 . "Buzz") '(7 . "Baxx"))</
{{out}}
Line 3,241:
(formerly Perl 6)
{{works with|rakudo|2015-09-20}}
<syntaxhighlight lang="raku"
# Defaults to standard FizzBuzz unless a new schema is passed in.
class FizzBuzz {
Line 3,268:
# And for fun
say 'Using: 21 ' ~ <2 Pip 4 Squack 5 Pocketa 7 Queep>;
say join ', ', GeneralFizzBuzz(21, <2 Pip 4 Squack 5 Pocketa 7 Queep>);</
{{Out}}
<pre>Using: 20 3 Fizz 5 Buzz 7 Baxx
Line 3,296:
Here's the same program in a more functional idiom:
<syntaxhighlight lang="raku"
[Z~](
do for @fb || <3 fizz 5 buzz> -> $i, $s {
Line 3,304:
}
.say for genfizzbuzz(20, <3 Fizz 5 Buzz 7 Baxx>);</
=={{header|Red}}==
<
nmax: to-integer ask "Max number: "
Line 3,320:
print either empty? res [n] [res]
]
halt</
{{Out}}
<pre>Max number: 21
Line 3,352:
=={{header|REXX}}==
=== idiomatic version ===
<
parse arg h $ /*obtain optional arguments from the CL*/
if h='' | h="," then h= 20 /*Not specified? Then use the default.*/
Line 3,367:
end /*k*/ /* [↑] Note: the factors may be zero.*/
say word(z j, 1) /*display the number or its factors. */
end /*j*/ /*stick a fork in it, we're all done. */</
{{out|output|text= when using the default input:}}
<pre>
Line 3,393:
=== optimized version ===
<
parse arg h $ /*obtain optional arguments from the CL*/
if h='' | h="," then h= 20 /*Not specified? Then use the default.*/
Line 3,403:
end /*k*/ /* [↑] Note: the factors may be zero.*/
say word(Z j, 1) /*display the number or its factors. */
end /*j*/ /*stick a fork in it, we're all done. */</
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br>
=={{header|Ring}}==
<
limit = 20
for n = 1 to limit
Line 3,416:
next
</syntaxhighlight>
=={{header|Ruby}}==
<
num, *nword = text.split
num = num.to_i
Line 3,436:
EOS
general_fizzbuzz(text)</
{{out}}
Line 3,464:
=={{header|Rust}}==
<
use std::io::BufRead;
Line 3,502:
}
}
}</
This solution stores the Fizz Buzz state in a struct, leveraging types and the standard library for a more general solution:
<
use std::fmt::{self, Write};
use std::io::{self, Stdin};
Line 3,630:
assert_eq!(expected, &printed);
}
}</
=={{header|Scala}}==
Line 3,667:
===Simple===
<
object GeneralFizzBuzz extends App {
Line 3,680:
println(if (words.nonEmpty) words.mkString else i)
}
}</
===LazyList (f/k/a Stream)===
<
object GeneralFizzBuzz extends App {
Line 3,701:
.sorted
fizzBuzz(factors).take(max).foreach(println)
}</
===Scala 3 (Dotty)===
{{trans|LazyList (f/k/a Stream)}}
<
def fizzBuzzTerm(n: Int, factors: Seq[(Int, String)]): String | Int =
Line 3,721:
.map { case Array(k, v) => k.toInt -> v }
.sorted
fizzBuzz(factors).take(max).foreach(println)</
=={{header|Sidef}}==
<
method filter(this) {
var fb = ''
Line 3,742:
}
GeneralFizzBuzz(20, <3 Fizz 5 Buzz 7 Baxx>).each { .say }</
{{out}}
<pre>
Line 3,771:
This is not a particularly efficient solution, but it gets the job done.
<syntaxhighlight lang="sql">
/*
This code is an implementation of "General FizzBuzz" in SQL ORACLE 19c
Line 3,784:
;
/
</syntaxhighlight>
{{out}}
Line 3,821:
=={{header|Swift}}==
<syntaxhighlight lang="text">import Foundation
print("Input max number: ", terminator: "")
Line 3,858:
print("\(factors.isEmpty ? String(i) : factors)")
}</
{{out}}
Line 3,888:
=={{header|Tailspin}}==
<
def input: {N: 110"1", words: [ { mod: 3"1", word: 'Fizz' }, { mod: 5"1", word: 'Buzz'}, {mod:7"1", word: 'Baxx'}]};
Line 3,902:
[ 1"1"..$input.N -> '$->sayWords;' ] -> \[i](<=''> $i ! <> $ !\) -> '$;
' -> !OUT::write
</syntaxhighlight>
{{out}}
<pre>
Line 3,913:
For fun, the below implementation is a compatible extension of [[FizzBuzz#Tcl]]:
<
if {$args eq ""} {
set args {{3 Fizz} {5 Buzz}}
Line 3,927:
}
}
fizzbuzz 20 {3 Fizz} {5 Buzz} {7 Baxx}</
=={{header|Ursa}}==
This program reads a max number, then reads factors until the user enters a blank line.
<
# general fizzbuzz
#
Line 3,971:
end if
out endl console
end for</
Output:
<pre>>20
Line 4,000:
=={{header|VBA}}==
<syntaxhighlight lang="vb">
Option Explicit
Line 4,034:
If StrPtr(UserChoice.Name) <> 0 And UserChoice.Number < MaxNumber Then ok = True
Loop
End Function</
{{out}}
With the entry :
Line 4,088:
=={{header|VBScript}}==
<
Function FizzBuzz(range, mapping)
data = Array()
Line 4,121:
y = WScript.StdIn.ReadLine
WScript.StdOut.WriteLine ""
FizzBuzz x, y</
{{Out|Sample Run}}
<pre>\Desktop>cscript /nologo fizzbuzz.vbs
Line 4,151:
=={{header|Visual Basic .NET}}==
<
Module Program
Line 4,179:
Next
End Sub
End Module</
{{out}}
Line 4,208:
=={{header|Vlang}}==
<
fn main() {
Line 4,237:
divisible = false
}
}</
{{out}}
<pre>Max: 20
Line 4,267:
=={{header|Wren}}==
{{libheader|Wren-sort}}
<
import "/sort" for Sort
Line 4,322:
if (s == "") s = i.toString
System.print(s)
}</
{{out}}
Line 4,357:
=={{header|zkl}}==
<
fizzBuzzers:=List();
do(3){ n,txt:=ask(">").split(); fizzBuzzers.append(T(n.toInt(),txt)) }
Line 4,363:
s:=fizzBuzzers.filter('wrap([(fb,txt)]){ n%fb==0 }).apply("get",1).concat();
println(s or n);
}</
{{out}}
<pre>
Line 4,395:
=={{header|ZX Spectrum Basic}}==
{{trans|BBC_BASIC}}
<
20 INPUT "Number of factors: ";n
30 DIM f(n): DIM w$(n,4)
Line 4,409:
130 PRINT
140 NEXT i
150 DEF FN m(a,b)=a-INT (a/b)*b</
|