| Bytes | Lang | Time | Link |
|---|---|---|---|
| 083 | AWK | 240820T183406Z | C K |
| 129 | Swift 5.9 | 240311T211555Z | macOSist |
| 084 | Javascript | 151117T125707Z | Nina Sch |
| 078 | JavaScript | 220125T015335Z | Matthew |
| 021 | Vyxal j | 220125T004437Z | lyxal |
| 088 | Python 3 | 200701T143133Z | hugovdbe |
| 029 | 05AB1E | 200701T134437Z | Kevin Cr |
| 080 | Mathematica | 151109T225941Z | LegionMa |
| 116 | ><> | 180212T205225Z | hakr14 |
| 078 | ><> | 180213T032957Z | Jo King |
| 155 | Javascript | 151112T171718Z | Solomon |
| 058 | Perl6 | 160824T165014Z | bb94 |
| 066 | Ruby | 151109T212739Z | MegaTom |
| 134 | F# | 160824T183906Z | asibahi |
| 642 | /// | 160618T214311Z | Erik the |
| 137 | Python 3 | 160615T184828Z | george |
| 118 | Haskell | 151111T112716Z | HaskellE |
| 108 | Javascript ES6 | 151118T162646Z | Scott |
| 182 | Prolog | 151117T143532Z | Emigna |
| 119 | ><> | 151110T215645Z | DanTheMa |
| 073 | PARI/GP | 151114T155832Z | primo |
| 121 | C | 151114T154520Z | Stefano |
| 075 | PHP | 151114T033617Z | primo |
| 047 | GolfScript | 151114T094846Z | primo |
| 074 | Perl | 151114T041415Z | primo |
| 149 | F# | 151112T205737Z | olegz |
| 084 | Wolfram Language | 151113T122104Z | Jacob Ak |
| 099 | Javascript ES2015 | 151112T202225Z | Sebastia |
| 079 | dc | 151112T174356Z | user4719 |
| 145 | C# | 151109T211439Z | olegz |
| 083 | ShapeScript | 151110T051821Z | Dennis |
| 146 | Perl | 151111T180506Z | Michael |
| 112 | Javascript ES6 | 151111T145241Z | mcfedr |
| 212 | Oracle SQL | 151110T114333Z | MT0 |
| 141 | QBasic | 151109T201402Z | steenber |
| 134 | JavascriptES6 | 151110T122952Z | Naouak |
| 320 | C# | 151109T191537Z | Jakothes |
| 308 | Java | 151110T162419Z | Sock |
| 044 | CJam | 151110T030035Z | Dennis |
| 127 | Clojure | 151109T225747Z | Sam Este |
| 348 | C++11 metaprogramming | 151109T184608Z | Zereges |
| 037 | Pyth | 151109T201352Z | PurkkaKo |
| 100 | Python 2 | 151109T175503Z | Blue |
| 121 | Python 2 | 151109T181606Z | Hannes K |
| 062 | Python 2 | 151109T180725Z | Sp3000 |
| 039 | Pyth | 151109T180608Z | FryAmThe |
| 051 | Pyth | 151109T174306Z | Blue |
AWK, 83 bytes
END{m=1;for(i=0;10^16>i;i=m+n){print i%2?i%3?i:y="Nacci":i%3?x="Fibo":x y;n=m;m=i}}
There's a caveat, AWK doesn't like to process bigints over about 10^16, so this gets to the ceiling - ymmv.
Swift 5.9, 129 bytes
let f={$0<3 ?1:f($0-UInt64(1))+f($0-2)},m="Fibo",n="Nacci"
for i in 1...30{print(i%12<1 ?m+n:i%3<1 ?m:i%4<1 ?n:"\(f(.init(i)))")}
Javascript, 93 90 86 84 Bytes
for(a=0,b=1,i=100;i--;a=[b,b+=a][0])console.log((b%2?'':'Fibo')+(b%3?'':'Nacci')||b)
JavaScript, 82 78 bytes
-4 bytes thanks to xigio
for(n=a=b=1;n++n<102;b=a+(a=b))alert((a%2n?'':'Fibo')+(a%3n?'':'Nacci')||a+'')
Uses JavaScript's BigInt (not supported in IE) to get to get all the way up to 100.
Vyxal j, 21 bytes
ÞF₁Ẏƛ₍₂₃«-∇j€₌p«⌈ǐ*∑∴
Basically the same as the standard 11 byte FizzBuzz with a few changes
Explained
ÞF₁Ẏƛ₍₂₃«-∇j€₌p«⌈ǐ*∑∴
ÞF₁Ẏ # The first 100 fibonacci numbers
ƛ # to each item n:
₍₂₃ # push a list [n % 2 == 0, n % 3 == 0]
«-∇j€₌p« # push the string "fibo nacci"
⌈ǐ # split on spaces and titlecase each
*∑ # vectorised string multiply and sum - this is like writing way of writing ("Fibo" * (n % 2 == 0) + "Naci" * (n % 3 == 0))
∴ # choose the greatest of n and that string. A number will always be greater than an empty string, and a non-empty string will always be greater than a number
# Just like the standard fizzbuzz, the `j` flag joins on newlines
Python 3, 100 94 88 bytes
a,b=0,1
exec("print(f\"{''if b%2else'Fibo'}{''if b%3else'Nacci'}\"or b);a,b=b,a+b;"*100)
05AB1E, 29 bytes
тENÅfDÑ23SÃvá.•iÑ+FÌ;•™#yèJ},
Inspired by @Grimmy's bottom answer of the 1, 2, Fizz, 4, Buzz challenge (doesn't work in the legacy version with S removed, because there is a bug in the compressed string .•iÑ+FÌ;•; the compiler probably thinks there is an open if/loop block due to the i/F..).
Explanation:
тE # Loop `N` in the range [1,100]:
NÅf # Get the N'th Fibonacci number
D # Duplicate it
Ñ # Pop this copy, and push a list of its divisors
23SÃ # Only keep the divisors [2,3]
v # Inner loop over those remaining divisors (or not if none are left):
á # Only leave the letters of the current top of the stack
# (to get rid of the Fibonacci number that was still on the stack)
.•iÑ+FÌ;• # Push compressed string "fibo nacci"
™ # Titlecase each: "Fibo Nacci"
# # Split it on spaces: ["Fibo","Nacci"]
yè # Index the current divisor `y` into it (0-based and with wraparound,
# so 2 will index into "Fibo" and 3 into "Nacci")
J # Join everything on the stack together
}, # After the inner loop: pop and print the top with trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•iÑ+FÌ;• is "fibo nacci".
Mathematica, 80 bytes
a=b_/;#∣b&;Print/@(Fibonacci@Range@100/.{a@6->FiboNacci,a@2->Fibo,a@3->Nacci})
Adaptation of my older FizzBuzz solution.
><>, 116 bytes
01:n1&61>.
ao:@+:v
vv?%2:<
">:3%?vv^16<
o>:3%?!v~v<&
bov"ci"< 6 ;
io" n 6~?
Focv1&< o=
"o">+:aa*!o^
>^>"aN"ooo^
><>, 78 bytes
01:n0\oo~o'F0ibo'\
aa:+1<}[3rn?/!?%3\!?%2:::::+}:}oa;?=*
ooooo'Nacci'/
00$0o\.
Javascript, 157 155 bytes
Golfed:
function g(n){a=!n%2;b=!n%3;a&&b?return "FiboNacci":;b?return "Nacci";a?return "Fibo";return n==1||n==2?1:f(n-1)+f(n-2)}for(n=100;n++>0;)console.log(f(n))
Ungolfed:
function fibonacci(n){
if(n==1||n==2) return 1;
return(fibonacci(n-1)+fibonacci(n-2));
}
function fibonacci2(n){
a=!(n%2);
b=!(n%3);
if(a&&b) return "FiboNacci";
if(a) return "Fibo";
if(b) return "Nacci";
return fibonacci(n);
}
for(n=100;n++>0;) console.log(fibonacci2(n));
Saved 3 bytes thanks to Cows Quack's comment
Perl6, 59 58
say "Fibo"x$_%%2~"Nacci"x$_%%3||$_ for (1,1,*+*...*)[^100]
Ruby, 71 66 bytes
a=b=1;100.times{puts [b,f='Fibo',n='Nacci',f,b,f+n][~b%6];a=b+b=a}
ungolfed:
a = b = 1 #starting values
100.times{
# create an array, and selects a value depending on the current number
puts([b, 'Fibo', 'Nacci', 'Fibo', b, 'FiboNacci'][~b%6])
a=b+b=a # magic
}
F#, 153 134 bytes
let rec L c n p=printfn"%s"(c%6m|>function|0m->"FiboNacci"|2m|4m->"Fibo"|3m->"Nacci"|_->string c);if n<100 then L(p+c)(n+1)c
L 1I 1 0I
Edit: Used decimal instead of bigint which allowed using pattern matching. Stole the internal logic from the other F# answer. My older filtering logic is in the below snippets.
One liner, same logic, 155 bytes:
let rec L c n p=printfn"%s"(if c%6I=0I then"FiboNacci"elif c%2I=0I then"Fibo"elif c%3I=0I then"Nacci"else string c);if n<100 then L(p+c)(n+1)c in L 1I 1 0I
Different logic, 168 bytes:
Seq.unfold(fun(p,c)->Some((if c%6I=0I then"FiboNacci"elif c%2I=0I then"Fibo"elif c%3I=0I then"Nacci"else string c),(c,c+p)))(0I,1I)|>Seq.take 100|>Seq.iter(printfn"%s")
///, 642 bytes
/A/
Fibo//B/
Nacci//*/ANacci
//^/AB
/1
1^5A
13BA
55
89*233
377^1597A
4181BA
17711
28657*75025
121393^514229A
1346269BA
5702887
9227465*24157817
39088169^165580141A
433494437BA
1836311903
2971215073*7778742049
12586269025^53316291173A
139583862445BA
591286729879
956722026041*2504730781961
4052739537881^17167680177565A
44945570212853BA
190392490709135
308061521170129*806515533049393
1304969544928657^5527939700884757A
14472334024676221BA
61305790721611591
99194853094755497*259695496911122585
420196140727489673^1779979416004714189A
4660046610375530309BA
19740274219868223167
31940434634990099905*83621143489848422977
135301852344706746049AB
Python 3, 137 bytes
Fun question with lots of new things I learnt in doing it. Python3 isn't a golfing language, but I suppose this isn't too bad
f=lambda n:n if n<2 else f(n-2)+f(n-1)
for n in range(100):t=f(-~n);x="Fibo"*(t%2==0)+"Nacci"*(t%3==0);print(x if t%2==0 or t%3==0 else t)
Hardest part was just to get it to only print the number
First line calculates the nth fib number. Second line joins Fibo and Nacci if it fits the rules an then it prints that string if it should else print the nth fib number.
Haskell, 150 143 126 118 bytes
main=putStr.unlines.take 100$0!1
x!y=d 3"Nacci"(d 2"Fibo"id)(show y):y!(x+y) where d z a f b|mod y z>0=f b|1>0=f""++a
ungolfed:
main =
putStr . unlines . take 100 $ f 0 1
f x y
= d 3 "Nacci" (d 2 "Fibo" id) (show y) : f y (x+y)
where
d z a g b
| mod y z > 0 = g b
| otherwise = g "" ++ a
Javascript (ES6), 117 108 bytes
let s=[1,1],i;for(i=1;i<101;s[++i]=s[i-1]+s[i-2]);s.map(n=>console.log((n%2?"":"Fibo")+(n%3?"":"Nacci")||n))
Sadly this breaks after the 77th number, because Javascript doesn't support numbers that high. I think this is still cool enough to warrant an answer, though.
It generates the entire range of numbers, then iterates with map to print out the appropriate string.
Takes advantage of the fact that console.log prints on a new line. Could also use alert, but that's more annoying.
Prolog, 182 bytes
f(A,B,X):-X<100,C is A+B,Z is X+1,(Y is B mod 6,Y=0->writeln('FiboNacci');(Y is B mod 2,Y=0->writeln('Fibo');(Y is B mod 3,Y=0->writeln('Nacci');writeln(B)))),f(B,C,Z).
p:-f(0,1,0).
Try it out online here
To run the program, use the query:
p.
><>, 128 119 bytes
111&v >:3%0=?v> v
?;ao>:2%0=?v :3%0=?v :n>:}+&:1+&aa*=
^oooo < ^ooooo <
>"obiF"^>"iccaN"^
I shamelessly stole borrowed an existing program FizzBuzz program and modified it to work for the Fibo Nacci sequence. It outputs numbers forever. Now it is fixed, i.e. it only outputs 100 numbers. Try it here.
PARI/GP, 76 73 bytes
Saved three bytes courtesy of Mitch Schwartz.
for(n=b=!a=1,99,b=a+a=b;print(if(b%2,"",Fibo)if(b%3,if(b%2,b,""),Nacci)))
Sample Usage
$ gp -qf < fibo-nacci.gp
C, 121 bytes
Had to go full __int128_t for this to work. printf doesn't know how to handle a 128bit integer, so the last four numeric values will be printed wrong. Still, it was fun to code, so here you go:
__int128_t a,b=1,c;i=100;main(){while(i--){c=b;b%=6;printf(b?b%2?b-3?"%lu\n":"Nacci\n":"Fibo\n":"FiboNacci\n",c);b=c+a;a=c;}}
compiled with gcc-4.8 fibo.c on x86_64.
PHP, 75 bytes
<?for(;4e20>$b=bcadd($a,$a=$b)?:1;)echo[Fibo][++$i%3].[Nacci][$i%4]?:$b,~õ;
Surpisingly competitive. Requres PHP v5.5 or higher. I assume default settings, as they are without an .ini (you may disable your local .ini with the -n option).
Sample Usage
$ php -n fibo-nacci.php
GolfScript, 47 bytes
100,{1.@{.@+}*;..2%!'Fibo'*\3%!'Nacci'*+\or}%n*
Explanation
100, # push 0..99
{ # map
1.@ # push 1 twice, rotate counting var to the top
{ # apply that many times
.@+ # copy the top, rotate and add
# if the stack is [a b], this produces: [a b b] -> [b b a] -> [b b+a]
}*
;.. # discard the top, duplicate twice
2%!'Fibo'*\ # divisible by 2 ? 'Fibo' : ''
3%!'Nacci'* # divisible by 3 ? 'Nacci' : ''
+\or # concatenate, if empty use the numeric value instead
}%
n* # join all with a newline
Perl, 74 bytes
map{print+(Fibo)[$_%2].(Nacci)[$_%3]||$_ for$a+=$b||1,$b+=$a}1..50
Requires the following command line option: -lMbigint, counted as 8.
Sample Usage
$ perl -lMbigint fibo-nacci.pl
Perl, 79 bytes
use bigint;map{print+(Fibo)[$_%2].(Nacci)[$_%3]||$_,$/for$a+=$b||1,$b+=$a}1..50
Same as above, without requiring any command line options.
F#, 202 163 149 bytes
Seq.unfold(fun(a,b)->printfn"%s"(a%6m|>function|0m->"FiboNacci"|2m|4m->"Fibo"|3m->"Nacci"|_->string a);Some(1,(b,a+b)))(1m,1m)|>Seq.take 100|>Seq.sum
This is an FSX (F# script) file
Wolfram Language, 84 bytes
Kind of cheating of course, because of the built in Fibonacci.
t=Fibonacci@Range@100;g=(t[[#;;;;#]]=#2)&;g[3,Fibo]g[4,Nacci]g[12,FiboNacci]Print/@t
Example command to run the script
/Applications/Mathematica.app/Contents/MacOS/WolframKernel -script ~/Desktop/fibo.wl
Javascript (ES2015), 99 bytes
f=n=>n<3?1:f(n-1)+f(n-2);for(i=0;i<100;)console.log((f(++i)%2?'':'Fibo')+(f(i)%3?'':'Nacci')||f(i))
Ungolfed:
// fibonacci function
var fibonacci = (n) => n < 3 ? 1 : fibonacci(n-1) + fibonacci(n-2) // (implicit return)
for (var i = 0; i<100;) {
var output = fibonacci(++i) % 2 !== 0 ? '' : 'Fibo';
output += fibonacci(i) % 3 !== 0 ? '' : 'Nacci';
console.log(output || fibonacci(i));
}
dc, 100 89 79 bytes
[sG[]]sx[dn]s01df[sbdlb+lbrdd2%d[Fibo]r0!=xnr3%d[Nacci]r0!=xn*0!=0APzZ3>o]dsox
Inspired by http://c2.com/cgi/wiki?DeeCee
C#, 175 171 152 145 bytes
class c{static void Main(){for(dynamic a=1m,b=a,c=0;c++<100;b=a+(a=b))System.Console.WriteLine(a%6>0?a%2>0?a%3>0?a:"Nacci":"Fibo":"FiboNacci");}}
Uncompressed:
class c {
static void Main()
{
for (dynamic a = 1m, b = a, c = 0; c++ < 100; b = a + (a = b))
System.Console.WriteLine(a%6>0?a%2>0?a%3>0?a:"Nacci":"Fibo":"FiboNacci");
}
}
ShapeScript, 83 bytes
11'1?1?+'77*2**!""'"%r
"@+@0?2%1<"Fibo"*1?3%1<"Nacci"*+0?_0>"@"*!#%'52*0?**!"'"$""~
Perl, 146 Bytes
use bigint;$a=$b=1;for$i(0..99){$l=($a%2==0?2:0)+($a%3==0?1:0);print$a if$l==0;print"Fibo"if$l&2;print"Nacci"if$l&1;print"\n";($a,$b)=($b,$a+$b);}
Uncompressed:
#!/usr/bin/perl
use bigint;
$a=$b=1;
for$i(0..99) {
$l=($a%2==0?2:0)+($a%3==0?1:0);
print $a if $l == 0;
print "Fibo" if $l & 2;
print "Nacci" if $l & 1;
print "\n";
($a,$b)=($b,$a+$b);
}
old version with 156 bytes...
use bigint;$a=$b=1;for$i(0..99){if($a%2==0){print"Fibo";print($a%3==0?"Nacci\n":"\n");}elsif($a%3==0){print"Nacci\n";}else{print"$a\n";}($a,$b)=($b,$a+$b);}
Uncompressed:
#!/usr/bin/perl
use bigint;
$a=$b=1;
for $i (0..99) {
if($a%2 == 0) {
print "Fibo";
print ($a%3 == 0 ? "Nacci\n" : "\n");
} elsif($a%3 == 0) {
print "Nacci\n";
} else {
print "$a\n";
}
($a,$b)=($b,$a+$b);
}
Javascript ES6 112 bytes
var f=(a,b,c)=>{if(!(99<c)){var d=a%2?"":"Fibo",e=a%3?"":"Nacci";console.log(d||e?d+e:n);f(b,a+b,c+1)}};f(1,1,0)
As with other JS answers, fails after 73rd number because of js use of floats
Oracle SQL, 212 bytes
Not a golfing language but I had to try...
Concatenating all the rows with \n:
WITH F(R,P,C)AS(SELECT 1,0,1 FROM DUAL UNION ALL SELECT R+1,C,P+C FROM F WHERE R<100)SELECT LISTAGG(NVL(DECODE(MOD(C,2),0,'Fibo')||DECODE(MOD(C,3),0,'Nacci'),''||C),CHR(13))WITHIN GROUP(ORDER BY R)||CHR(13)FROM F
Or with one entry from the sequence per row (162 bytes):
WITH F(R,P,C)AS(SELECT 1,0,1 FROM DUAL UNION ALL SELECT R+1,C,P+C FROM F WHERE R<100)SELECT NVL(DECODE(MOD(C,2),0,'Fibo')||DECODE(MOD(C,3),0,'Nacci'),''||C)FROM F
QBasic, 144 141 bytes
Not particularly small, but it beats C++ and C#
r=1:FOR i=1 TO 046:a$="":q=p+r
IF q MOD 2=0 THEN a$="Fibo"
IF q MOD 3=0 THEN a$=a$+"Nacci"
IF a$="" THEN a$=STR$(q)
PRINT a$:r=p:p=q:NEXT
No declarations, used the : wherever possible because it's 1 byte cheaper than CRLF. Prefixed a 0 to the loop counter: Basic will overflow on the 47th Fibonacci character, so compensated for the extra byte that should be there.
EDIT: Neil saved me 3 bytes: 141 bytes.
Javascript(ES6), 137 134 bytes
g=x=>(a=[1,1],f=(x)=>(a[x]=y=a[x-1]+a[x-2],(y%2&&y%3?y:(!(y%2)?'Fibo':'')+(!(y%3)?'Nacci':''))+'\n'+((++x<99)?f(x):'')),'1\n1\n'+f(2))
Recursive function that calculates fibonnacci, put it in an array then output Fibo,Nacci or the number and call itself to calculate next until 100.
It breaks at 73 because of javascript Number precision. Only way to get around that would be to add my own bit calculation.
C#, 498 392 320 bytes
I just really wanted to do this with linq, too bad I had to write my own sum function for BigInteger that really killed it :-(
using System.Linq;using System.Numerics;using System.Collections.Generic;static class a{static void Main(){var f=new List<BigInteger>(){1,1};while(f.Count<100)f.Add(f.Skip(f.Count-2).Take(2).Aggregate((a,b)=>b+a));f.ForEach(x=>{System.Console.WriteLine(x%6==0?"FiboNacci":x%2==0?"Fibo":x%3==0?"Nacci":x.ToString());});}}
Ungolfed:
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
static class a
{
static void Main()
{
var f=new List<BigInteger>(){1,1};
while(f.Count<100)
f.Add(f.Skip(f.Count-2).Take(2).Aggregate((a,b)=>b+a));
f.ForEach(x=>
{
System.Console.WriteLine(x%6==0?"FiboNacci":x%2==0?"Fibo":x%3==0?"Nacci":x.ToString());
});
}
}
Edit: Down to 320 bytes thanks to LegionMammal978 for the aggregate suggestion and thanks to olegz's C# answer for the x%6 shorthand for X%2 && x%3 as well as the use of ternary operators in a single WriteLine statement.
Java, 407 398 351 308 bytes
Golfed it with help from @Geobits and @SamYonnou
Spread the word: Verbose == Java
import java.math.*;class A{public static void main(String[]w){BigInteger a=BigInteger.ZERO,b=a.flipBit(0),c,z=a,t=a.flipBit(1),h=t.flipBit(0),s=t.flipBit(2);for(int i=0;i<100;i++){System.out.println(b.mod(s).equals(z)?"FiboNacci":b.mod(t).equals(z)?"Fibo":b.mod(h).equals(z)?"Nacci":b);c=a;a=b;b=c.add(b);}}}
Ungolfed version:
import java.math.*;
class A
{
public static void main(String[]w)
{
BigInteger a=BigInteger.ZERO,b=a.flipBit(0),c,z=a,t=a.flipBit(1),h=t.flipBit(0),s=t.flipBit(2);
for(int i=1;i<=100;i++) {
System.out.println(b.mod(s).equals(z)?"FiboNacci":b.mod(t).equals(z)?"Fibo":b.mod(h).equals(z)?"Nacci":b);
c=a;a=b;b=c.add(b);
}
}
}
Clojure, 127 bytes
(def f(lazy-cat[1 1](map +' f(rest f))))(doseq[x(take 100 f)](println(str(if(even? x)'Fibo)({0'Nacci}(mod x 3)(if(odd? x)x)))))
Ungolfed:
(def fib (lazy-cat [1 1] (map +' fib (rest fib))))
(doseq [x (take 100 fib)]
(println (str (if (even? x) 'Fibo)
({0 'Nacci}
(mod x 3)
(if (odd? x) x)))))
Some tricks used:
- That pretty little
defthat gives the Fibonacci sequence itself is stolen shamelessly from Konrad Garus. strcan take symbols as input. Crazy, right?- Maps and default values are the shortest way to write
ifin some cases.
C++11 metaprogramming, 348 bytes
#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}
Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)
Ungolfed
#include <iostream>
#define D static const unsigned long long v =
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };
template<int Z>struct S : S<Z - 1>
{
S()
{
auto&s = std::cout;
auto l = F<Z>::v;
s << (l % 2 ? "" : "Fibo")
<< (l % 3 ? "" : "Nacci");
(l % 2 && l % 3 ? s << l : s) << "\n";
}
};
template<>struct S<0>
{
S() { }
};
int main()
{
S<100>s;
}
Pyth, 37 bytes
I loop through the Fibonacci numbers instead of generating them beforehand, since it's really short to do.
K1V100|+*"Fibo"!%=+Z~KZ2*"Nacci"!%Z3Z
Python 2, 100 bytes
x=[1,1]
exec"x+=[x[-1]+x[-2]];"*98
print"\n".join(["Fibo"*(i%2==0)+"Nacci"*(i%3==0)or`i`for i in x])
For the large numbers, adds a L to the end showing it's a long number.
If that's a problem, here is a 104 byte solution
x=[1,1]
exec"x+=[x[-1]+x[-2]];"*98
print"\n".join(["Fibo"*(i%2==0)+"Nacci"*(i%3==0)or str(i)for i in x])
Python 2, 171 121 bytes
"Brute force approach."
a=[1,1]
print 1
for _ in"q"*99:print[a[1],"Fibo","Nacci","FiboNacci"][a.append(a.pop(0)+a[0])or(1-a[0]%2)+(a[0]%3<1)*2]
Python 2, 62 bytes
a=b=1;exec"print~a%2*'Fibo'+~a%3/2*'Nacci'or a;a,b=b,a+b;"*100
Not much different from the standard FizzBuzz, really.
Pyth, 39
Vtu+Gs>2G99U2|+*!%N2"Fibo"*!%N3"Nacci"N
Very similar to the standard fizzbuzz solution, just with a generator for the Fibonacci numbers.
Pyth, 51 bytes
V.Wn100lHaZ+@Z_1@Z_2[1 1)|+*"Fibo"}2JPN*"Nacci"}3JN
Generates the Fibonacci sequence then decides what to print.
[1 1) - H = [1,1]
Wn100lH - While len(H)!=100
aZ+@Z_1@Z_2 - H.append(H[-1]+H[-2])
V. - For N in H:
JPN - Set J to the prime factorization of H
*"Fibo"}2J - If there is a 2 in the factorization, add "Fibo" to a string
*"Nacci"}3J - If there is a 3 in the factorization, add "Nacci" to a string
+ - Join them together
| N - If the string isn't empty (If it isn't divisible by 2 or 3), print N
- Else print the string
To test, try this (only does the first 20 numbers)
V.Wn20lHaZ+@Z_1@Z_2[1 1)|+*"Fibo"}2JPN*"Nacci"}3JN