Fibonacci + Fizz Buzz = Fibo Nacci!

74

8

Fibonacci + FizzBuzz = Fibo Nacci!


Your challenge is to create a Fibo Nacci program!

  • A Fibo Nacci program outputs the first 100 Fibonacci numbers (starting from 1).
  • If the Fibonacci number is divisible by both 2 and 3 (i.e. it is divisible by 6), then output FiboNacci instead of the number.
  • Otherwise, if the Fibonacci number is divisible by 2, then output Fibo instead of the number.
  • Otherwise, if the Fibonacci number is divisible by 3, then output Nacci instead of the number.

Rules

  • The program should take no input.
  • The program should output a new line (\n) after every entry.
  • The program should not print anything to STDERR.
  • The program must output the first 100 Fibo Nacci entries (starting from 1).
  • Standard loopholes are not allowed (by default).
  • This is so shortest code in bytes wins!

Here is the expected output:

1
1
Fibo
Nacci
5
Fibo
13
Nacci
Fibo
55
89
FiboNacci
233
377
Fibo
Nacci
1597
Fibo
4181
Nacci
Fibo
17711
28657
FiboNacci
75025
121393
Fibo
Nacci
514229
Fibo
1346269
Nacci
Fibo
5702887
9227465
FiboNacci
24157817
39088169
Fibo
Nacci
165580141
Fibo
433494437
Nacci
Fibo
1836311903
2971215073
FiboNacci
7778742049
12586269025
Fibo
Nacci
53316291173
Fibo
139583862445
Nacci
Fibo
591286729879
956722026041
FiboNacci
2504730781961
4052739537881
Fibo
Nacci
17167680177565
Fibo
44945570212853
Nacci
Fibo
190392490709135
308061521170129
FiboNacci
806515533049393
1304969544928657
Fibo
Nacci
5527939700884757
Fibo
14472334024676221
Nacci
Fibo
61305790721611591
99194853094755497
FiboNacci
259695496911122585
420196140727489673
Fibo
Nacci
1779979416004714189
Fibo
4660046610375530309
Nacci
Fibo
19740274219868223167
31940434634990099905
FiboNacci
83621143489848422977
135301852344706746049
Fibo
Nacci

The Catalogue

The Snack Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

/* Configuration */

var QUESTION_ID = 63442; // Obtain this from the url
// It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 41805; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "http://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "http://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list">
  <h2>Shortest Solution by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

user41805

Posted 2015-11-09T17:11:53.600

Reputation: 16 320

6What about languages with highest integer type of only 64 bits? :( Isn't 90 fib. numbers enough? – Zereges – 2015-11-09T18:15:11.443

3@Zereges In that matter, I am sorry. :( – user41805 – 2015-11-09T19:30:45.283

Do you mean "at least 100"? Or is printing more than 100 not allowed? – mbomb007 – 2015-11-09T22:54:15.653

28Maybe it should be called "Fizzo Nacci" – LegionMammal978 – 2015-11-09T22:56:31.843

@mbomb007 Where is the "at least"? – user41805 – 2015-11-10T19:01:31.267

1@ΚριτικσιΛίθος It never says "at least". I think the point of the question is if it would be allowed to print more than 100 Fibo Nacci numbers. – DanTheMan – 2015-11-10T21:48:06.250

@DanTheMan The program should only output the first 100 Fibo Nacci numbers, no more, no less. – user41805 – 2015-11-11T05:30:19.107

Would be a much better question if it only required native int support :( – SztupY – 2015-11-11T13:55:32.213

@SztupY If I were to make a change now, everyone else's answers would have to change to just the first 80 or 90 numbers. – user41805 – 2015-11-11T18:56:02.943

4@SztupY Because the output in this question is completely invariant, you don't even need integers at all. Just treat this question as a [tag:kolmogorov-complexity] question (I even added the tag) and go from there. – Chris Jester-Young – 2015-11-12T17:43:49.457

3@ChrisJester-Young it's still an unnecessarry limitation, that might make creative implementators steer clear of this task. And most of the solutions (including the 2nd most upvoted one) are breaking already – SztupY – 2015-11-12T19:24:46.770

2:( @ approx-66-bit int requirement – Sparr – 2015-11-18T17:24:29.653

Fibo Nazi (lol) – None – 2016-07-01T09:45:22.777

3Math comment: every third Fibonacci number is even, and every fourth Fibonacci number is a multiple of 3. This might lead to alternate coding strategies, which don't require testing divisibility. – Greg Martin – 2016-08-24T18:14:20.720

Related – Erik the Outgolfer – 2016-09-22T10:56:17.340

Answers

18

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

Try it online.

PurkkaKoodari

Posted 2015-11-09T17:11:53.600

Reputation: 16 699

Congratulations for winning this challenge! I liked that this solution was fast. – user41805 – 2015-11-15T19:45:00.247

45

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.

Sp3000

Posted 2015-11-09T17:11:53.600

Reputation: 58 729

1This is amazing. – J Atkin – 2015-11-10T18:15:53.830

I need to remember this looping construct for my next Ruby golf. This is amazing. – clap – 2015-11-16T16:28:04.980

21

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;
}

Zereges

Posted 2015-11-09T17:11:53.600

Reputation: 1 165

You could use exploded strings (template <char H, char ...T>) in your templates to (theoretically) handle arbitrary-length values. Then it would just be a matter of examining the last 2 characters in each string to determine divisibility by 2 and/or 3. – Mego – 2015-11-09T20:23:45.020

@Mego I do not understand you. How it would help me to handle values, which do not fit into 64 bits. Also, You need all digits to find out if the number is divisible by 3. – Zereges – 2015-11-09T21:12:20.830

Strings can be arbitrarily long (until you run out of memory). And you're right, I messed up my comment. Still, you could compute the digital sum to determine divisibility by 3. – Mego – 2015-11-09T21:27:21.527

@Mego Implementing addition of those strings would require much more effort. – Zereges – 2015-11-09T22:17:41.360

Perhaps, but at least it would be a valid entry. – Mego – 2015-11-10T02:25:02.270

1You could use the gnu dialect and use __uint128_t, maybe. – None – 2015-11-12T21:54:08.703

14

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");
    }
}

olegz

Posted 2015-11-09T17:11:53.600

Reputation: 251

Even compressing the output with a DeflateStream the lowest I could get was 191 chars so this is likely very close to the best possible c# answer. A shame BigInteger is required. – Jodrell – 2015-11-10T10:28:14.143

"using System;" will give another -1 in size. – olegz – 2015-11-10T17:18:22.360

1I still had to prefix System.Numerics with System despite the using :-S, so I'm not sure the using will work. – Jodrell – 2015-11-10T17:22:27.373

Yes, the same here (under Mono) :( – olegz – 2015-11-10T18:10:05.213

Another trick to make it 3 bytes shorter – olegz – 2015-11-10T18:44:41.987

1You can save 3 characters by replacing the ==0s with >0 and inverting the ternaries: class c{static void Main(){for(System.Numerics.BigInteger a=1,b=1,c=0;c++<100;b=a+(a=b))System.Console.WriteLine(a%6>0?a%2>0?a%3>0?a:(object)"Nacci":"Fibo":"FiboNacci");}} – Bob – 2015-11-11T04:53:00.563

That's a great idea! Let me check – olegz – 2015-11-11T09:04:24.517

3You can save another 7 characters by changing decimal a=1,b=1 to dynamic a=1m,b=a and then you can lose the (object) :) – Timwi – 2015-11-11T21:58:51.937

Great, @Timwi! That gonna be final word. – olegz – 2015-11-12T07:18:50.217

Using dynamic is pretty clever – asibahi – 2016-08-24T17:53:18.430

13

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

SQLFIDDLE

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

MT0

Posted 2015-11-09T17:11:53.600

Reputation: 3 373

2Awesome, just for using SQL – Wayne Werner – 2015-11-10T14:23:14.253

Just use the last one, since it is the "equivalent" to outputting "per line". And it really is a fine piece of code. Well done! – Ismael Miguel – 2015-11-11T09:20:05.430

@IsmaelMiguel If it's run in SQL*Plus (or another command line interface) then there will be a newline output after each row (as part of how it reports the query output). However, that is a function of the CLI and not the SQL language - to be compliant with the rule The program should output a new line (\n) after every entry I'll leave it as the longer code but the shorter one could be made compliant (without relying on a CLI) by adding ||CHR(13) before the final FROM for 171 chracters. – MT0 – 2015-11-11T10:30:17.777

Couldn't you use "\n"? Seems to work on MySQL. (Running select length("\n") returns 1, and running select "\n" doesn't return n, as with select "\p" returns p due to being an invalid escape) – Ismael Miguel – 2015-11-11T10:33:12.980

SELECT LENGTH('\n') FROM DUAL outputs 2 in Oracle as '\n' does not get converted to CHR(13). – MT0 – 2015-11-11T10:43:55.230

11

ShapeScript, 83 bytes

11'1?1?+'77*2**!""'"%r
"@+@0?2%1<"Fibo"*1?3%1<"Nacci"*+0?_0>"@"*!#%'52*0?**!"'"$""~

Try it online!

Dennis

Posted 2015-11-09T17:11:53.600

Reputation: 196 637

15Literally looks like my cat jumped on top of my keyboard while I tried to turn on sticky keys. Nice job. – phase – 2015-11-10T05:38:39.423

2@phase figuratively. Either that or you're not looking too closely. Or you have a tiny cat or a giant keyboard. Because this cat managed to type Fibo and Nacci but otherwise avoid all letter keys save for one r. – John Dvorak – 2015-11-10T13:50:54.797

3@JanDvorak I think phase has macros setup for that ;) – Wayne Werner – 2015-11-10T14:22:12.040

2@phase 1. Why is your cat in your room?; 2. why would you want to turn on sticky keys? 3? Why do you not have a cat trap box on your desk to avoid your cat jumping on your keyboard? – Nzall – 2015-11-11T23:55:02.750

7

Mathematica, 80 bytes

a=b_/;#∣b&;Print/@(Fibonacci@Range@100/.{%@6->FiboNacci,%@2->Fibo,%@3->Nacci})

Adaptation of my older FizzBuzz solution.

LegionMammal978

Posted 2015-11-09T17:11:53.600

Reputation: 15 731

1@JacobAkkerboom Sorry, fixed. Also, for versions less than 10.3, replace Echo with Print. – LegionMammal978 – 2015-11-24T13:31:45.347

7

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);
    }
  }
}

Sock

Posted 2015-11-09T17:11:53.600

Reputation: 71

1

This can be golfed more. Import java.math.* instead of the whole thing. Use the constants for ONE and ZERO instead of new BigIntegers. Remove the public from the class. Pack everything except the println statement in the for body inside the loop declaration, etc. I recommend looking over the Java golfing tips in general.

– Geobits – 2015-11-10T16:50:37.750

@Geobits Done! 'Twas a pity that I was unfamiliar with BigInteger and its various golfing techniques. – Sock – 2015-11-10T17:05:15.643

Storing BigInteger.ZERO, using flipBit(...) as an alternative to new BigInteger(...), and some other minor things you can get it down to 308: 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);}}} – SamYonnou – 2015-11-10T17:26:01.263

Looks like BigInteger always returns BigInteger.ZERO when some operation like add(...) evaluates to zero so you can use == instead of .equals(z), also you can do away with storing s=t.flipBit‌​(2) (6) and instead do some clever inner assignment like so: import java.math.*;class A{public static void main(String[]w){BigInteger a=BigInteger.ZERO,b=a.flipBit(0),c,d,z=a,t=a.flipBit(1),h=t.flipBit(0);for(int i=0;i<100;i++){System.out.println((c=b.mod(t)).add(d=b.mod(h))==z?"FiboNacci":c==z?"Fibo":d==z?"Nacci":b);c=a;a=b;b=c.add(b);}}} these changes get it down to 280 – SamYonnou – 2015-11-10T18:00:02.537

Oh and for the same reason you can use == for comparing to zero you can use it for the inner assignment bit and replace (c=b.mod(t)).add(d=b.mod(h))==z with (c=b.mod(t))==(d=b.mod(h)) bringing the total length to 275 – SamYonnou – 2015-11-10T18:32:53.583

Take advantage of the Properties of the Fibonacci numbers and you can do it with 42 chars less: Remove the variable z and change the println to System.out.println(i%12==0?"FiboNacci":i%3==0?"Fibo":i%4==0?"Nacci":b); https://en.wikipedia.org/wiki/Fibonacci_number#Primes_and_divisibility

– Fabian Tschachtli – 2015-11-11T09:49:22.043

@FabianTschachtli The % cannot be used on a BigInteger. That is why I use the .mod() function. – Sock – 2015-11-11T19:38:49.557

@Sock Notice that he is using % on i, not the BigInteger. For Fibonacci numbers the divisibility of the number is related to divisibility of the index in the sequence, see the WP link. – Mario Carneiro – 2015-11-11T20:08:34.973

interface a{static void .... – Rohan Jhunjhunwala – 2016-07-21T02:46:03.153

2I think you mean Verbose.isEqualTo(Java) – Cyoce – 2016-08-24T22:46:50.850

5

><>, 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^

Try it online!

hakr14

Posted 2015-11-09T17:11:53.600

Reputation: 1 295

6Welcome to the site! :) – James – 2018-02-12T20:54:59.517

You could probably combine both the 3% sections – Jo King – 2018-02-13T02:22:50.457

@JoKing You'd think so, but they actually lead to different outcomes if n%3!=0. I'm sure there is a way to combine them, but it would mean restructuring the entire program, and I imagine it would actually be longer. – hakr14 – 2018-02-13T02:40:04.540

5

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
}

MegaTom

Posted 2015-11-09T17:11:53.600

Reputation: 3 787

I've worked on this for longer than I'd like to admin and can't find any way to improve it. f,n=%w[Fibo Nacci],f,n='Fibbo','Nacci' and f='Fibbo';n='Nacci' all have the same character count. +1 – Shelvacu – 2015-11-10T22:56:29.197

1You can save three bytes by using [b,f='Fibo',n='Nacci',f,b,f+n][~b%6], and two more by removing the parentheses in a=b+b=a. – primo – 2015-11-14T05:27:07.870

Thank you @primo. That is a neat trick with the ~ operator. Never seen it before. And now I know why negative indexes are part of ruby:) – MegaTom – 2015-11-16T16:28:47.637

Really need puts [ instead of puts[? – Erik the Outgolfer – 2016-06-18T21:52:32.137

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ yes. puts[...][...] groups as (puts[...])[...] rater than puts([...][...]) – MegaTom – 2016-06-21T01:43:10.357

1Roses are red, Violets are blue, for Haskell and Ruby, I have no clue. – Erik the Outgolfer – 2016-06-21T08:22:14.737

I love the symmetry in a=b+b=a – Cyoce – 2016-08-24T22:48:18.310

4

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.

Try it here

FryAmTheEggman

Posted 2015-11-09T17:11:53.600

Reputation: 16 206

4

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.

Jakotheshadows

Posted 2015-11-09T17:11:53.600

Reputation: 209

4Have you heard of the Aggregate LINQ function? – LegionMammal978 – 2015-11-09T22:55:01.327

Replace "sum" with "t" to shave 6 bytes. – Xantix – 2015-11-10T01:42:51.910

3

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]

Hannes Karppila

Posted 2015-11-09T17:11:53.600

Reputation: 3 090

3

Javascript, 93 90 86 Bytes

for(a=0,b=1,i=100;i--;a=[b,b=a+b][0])console.log((b%2?'':'Fibo')+(b%3?'':'Nacci')||b)

Nina Scholz

Posted 2015-11-09T17:11:53.600

Reputation: 131

1You could save four bytes by changing a=[b,b=a+b][0] to b=a+b,a=b-a. Also, in a completely unrelated note, I like the way you answer like really fast in Stack Overflow hehe Have a nice day – Piyin – 2017-11-02T22:22:39.057

2

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])

Blue

Posted 2015-11-09T17:11:53.600

Reputation: 26 661

You can shorten the for loop using this tip: http://codegolf.stackexchange.com/a/5047/42736. In particular the exec tip looks good.

– J Atkin – 2015-11-09T19:19:10.283

+1 for the exec <program_string>*n trick. Nice! – agtoever – 2015-11-10T09:01:29.890

2

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.

steenbergh

Posted 2015-11-09T17:11:53.600

Reputation: 7 772

You can remove the first a$+ since it's known to be the empty string at this point. – Neil – 2015-11-11T08:40:32.703

2

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.

Naouak

Posted 2015-11-09T17:11:53.600

Reputation: 349

This doesn't work, it goes wrong after 5527939700884757 + 8944394323791464 = 14472334024676220 when it should be 14472334024676221 because JavaScript uses 16 bit precision floats and that requires 17 bits of precision. You should also print 1 twice. – George Reith – 2015-11-10T17:31:20.357

Added the print 1 twice. For the precision, I need to change everythin on the code to make it work (not using Number but Uint32Array and doing computation bits by bits) – Naouak – 2015-11-10T22:18:30.413

2

><>, 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.

DanTheMan

Posted 2015-11-09T17:11:53.600

Reputation: 3 140

2You must only output the first 100 Fibo Nacci numbers, no more, no less. – user41805 – 2015-11-11T05:31:55.900

@ΚριτικσιΛίθος I finally got around to making it only output 100 numbers. – DanTheMan – 2015-11-18T16:52:45.560

This outputs 101 numbers on TIO but doesn't work at the linked site – Jo King – 2018-02-13T04:10:29.780

2

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

Jacob Akkerboom

Posted 2015-11-09T17:11:53.600

Reputation: 121

2

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.

primo

Posted 2015-11-09T17:11:53.600

Reputation: 30 891

2

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

primo

Posted 2015-11-09T17:11:53.600

Reputation: 30 891

2

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

primo

Posted 2015-11-09T17:11:53.600

Reputation: 30 891

1It's shorter not to use built-in; I got 73 with for(i=b=!a=1,99,b=a+a=b; ... – Mitch Schwartz – 2015-11-14T18:39:38.867

1@MitchSchwartz it used to be called fibo ;) – primo – 2015-11-14T23:12:38.560

1

><>, 78 bytes

01:n0\oo~o'F0ibo'\
aa:+1<}[3rn?/!?%3\!?%2:::::+}:}oa;?=*
ooooo'Nacci'/
00$0o\.

Try it online!

Jo King

Posted 2015-11-09T17:11:53.600

Reputation: 38 234

1

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

Blue

Posted 2015-11-09T17:11:53.600

Reputation: 26 661

How long does it take to run the actual program? – user41805 – 2015-11-09T17:45:26.527

I have no idea, it didn't in the 30 seconds it took to work out that working out such large prime factorizations would probably slow it down a lot. – Blue – 2015-11-09T17:46:37.197

1

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 def that gives the Fibonacci sequence itself is stolen shamelessly from Konrad Garus.
  • str can take symbols as input. Crazy, right?
  • Maps and default values are the shortest way to write if in some cases.

Sam Estep

Posted 2015-11-09T17:11:53.600

Reputation: 251

What is lazy-cat? – user41805 – 2015-11-10T05:02:44.463

@ΚριτικσιΛίθος It lazily concatenates multiple sequences. In this case, it concatenates the first two elements of the Fibonacci sequence ([1 1]) with the result of summing each element in the Fibonacci sequence with the element following it. – Sam Estep – 2015-11-10T11:54:03.793

Am I right in guessing that this is basically the Clojure version of fibs = 0 : 1 : zipWith (+) fibs (tail fibs)? – Soham Chowdhury – 2015-11-10T13:09:59.197

@SohamChowdhury Yes, as far as I can tell. – Sam Estep – 2015-11-10T13:14:11.827

1

CJam, 44 bytes

XX{_2$+}98*]{_B4bf%:!"Fibo Nacci"S/.*s\e|N}/

Try it online in the CJam interpreter.

Dennis

Posted 2015-11-09T17:11:53.600

Reputation: 196 637

1

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

HaskellElephant

Posted 2015-11-09T17:11:53.600

Reputation: 111

Why ; instead of ;? – Leif Willerts – 2015-11-18T21:47:37.513

Oups, missed that one byte @LeifWillerts :). – HaskellElephant – 2015-12-07T11:26:39.613

Well, seems like that "inspired" to improve much more :) – Leif Willerts – 2015-12-07T19:36:16.797

What does d do? – Cyoce – 2016-08-24T23:43:03.830

1

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

user47197

Posted 2015-11-09T17:11:53.600

Reputation: 19

Welcome to Programming Puzzles & Code Golf! – Dennis – 2015-11-12T18:05:39.550

1

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));
}

Sebastian Sandqvist

Posted 2015-11-09T17:11:53.600

Reputation: 111

Use alert instead of console.log; it shaves off some bytes. – user41805 – 2015-11-13T06:28:04.320

1

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

olegz

Posted 2015-11-09T17:11:53.600

Reputation: 251

I am surprised that this works – asibahi – 2016-08-24T19:35:42.523

1

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

primo

Posted 2015-11-09T17:11:53.600

Reputation: 30 891

WIth -n bcadd doesn't work even when bcmath is installed. Without -n lots of stuff is output on stderr. – Sylwester – 2018-02-12T21:10:33.297

Works on my box(es). – primo – 2018-02-13T08:35:08.110

1

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.

Emigna

Posted 2015-11-09T17:11:53.600

Reputation: 50 798

1

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))

Try it online here.

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.

Scott

Posted 2015-11-09T17:11:53.600

Reputation: 217

0

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

mcfedr

Posted 2015-11-09T17:11:53.600

Reputation: 101

Why var? You can save 8 bytes omitting it, making globals instead. There is no consensus saying that functions can't create globals. Also, you can omit f=, making an anonymous function, saving another -2 bytes. Final save: -10 bytes Final size: 102 bytes – Erik the Outgolfer – 2016-06-18T21:59:12.507

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);
}

Michael

Posted 2015-11-09T17:11:53.600

Reputation: 126

0

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

Solomon Ucko

Posted 2015-11-09T17:11:53.600

Reputation: 439

Thanks! By the way, why is there a minimum comment length? – Solomon Ucko – 2015-11-12T21:02:26.637

There is a minimum comment length to prevent comments like "Good Job!" or "+1" and stuff like that. – user41805 – 2015-11-13T06:26:09.937

@ΚριτικσιΛίθος Why is there also a minimum amount of reputation to be able to post comments then? – Solomon Ucko – 2015-11-15T23:32:22.647

Change your for-loop to for(n=100;n++>0;)console.log(f(n)) It saves 3 bytes – user41805 – 2015-11-16T14:24:24.590

@ΚριτικσιΛίθος OK, thanks. Editing post. – Solomon Ucko – 2015-11-16T22:16:11.763

I am unable to run this, I get a syntax error – user41805 – 2018-05-17T09:45:43.990

0

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.

Stefano Sanfilippo

Posted 2015-11-09T17:11:53.600

Reputation: 1 059

while is always longer than or as long as for. – Jonathan Frech – 2018-02-12T21:51:13.207

0

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.

george

Posted 2015-11-09T17:11:53.600

Reputation: 1 495

12else instead of 2 else for -1 byte, n+1 instead of -~n because -~n is unneeded, t%2<1 instead of t%2==0 for -1 byte, t%3<1 instead of t%3==0 for -1 byte, t%2<1or t%3<1else instead of t%2==0 or t%3==0 else for -4 bytes. Total save: -7 bytes. – Erik the Outgolfer – 2016-06-18T21:48:08.843

0

///, 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

Erik the Outgolfer

Posted 2015-11-09T17:11:53.600

Reputation: 38 134

0

Perl6, 59 58

say "Fibo"x$_%%2~"Nacci"x$_%%3||$_ for (1,1,*+*...*)[^100]

bb94

Posted 2015-11-09T17:11:53.600

Reputation: 1 831

0

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")

asibahi

Posted 2015-11-09T17:11:53.600

Reputation: 371