g | x | w | all
Bytes Lang Time Link
077YASEPL250905T173701Zmadeforl
027Stax210217T162011ZRazetime
062Perl 6190531T004502ZSean
02305AB1E190528T172316ZGrimmy
046J161025T205918Zmiles
446BrainFlak 446 Bytes161025T145559ZRiley
064Haskell161025T200706Znimi
03005AB1E161025T140211ZEmigna
075Perl161025T171752ZGabriel
063JavaScript161025T141511ZETHprodu
070R161025T144643ZJDL
110Batch161025T151145ZNeil
076Python 2161025T135434ZKade
072Python 3161025T135133ZTheNumbe
120C#161025T143056ZKade
316Java 7161025T132921ZKevin Cr

YASEPL, 77 bytes

=n$2¶f$`1>f¶d$n+f¶A$d%¶B$d%3=b^B¶C$d%4=c^C!-!c*n+!+¶f^A-b*n+d*c!+}2,102

I kinda cheated on this, because I added BigInt support for it to work, lol. I needed to add it anyway.

explanation:

=n$2¶f$`1>f¶d$n+f¶A$d%¶B$d%3=b^B¶C$d%4=c^C!-!c*n+!+¶f^A-b*n+d*c!+}2,102         packed
=n$2                                                                            n = 2
    ¶f$                                                                         f = 1
       `1                                                      !+}2,102         while n < 102...
         >f                                                                         print f 
           ¶d$n+f                                                                   set d to n + f
                 ¶A$d%                                                              A = d % 2
                      ¶B$d%3=b^B                                                    b = not(d % 3)
                                ¶C$d%4=c^C!-!c*n+!+                                 c = not(d % 4) * (n - 1) + 1
                                                   ¶f^A-b*n+d*c                     f = (((not(A) - b) * n) + d) * c
                                                               !+                   increment n and check loop

output:

1n
1n
21n
25n
30n
216n
223n
223n
2169n
2179n
2190n
2202n
2215n
2215n
2245n
2261n
2295n
2295n
2333n
2353n
2395n
2417n
56649n
56649n
56699n
56725n
1533033n
1533061n
1533090n
45993600n
45993631n
45993631n
1517792001n
1517792035n
1517792070n
1517792106n
1517792143n
1517792143n
1517792221n
1517792261n
1517792343n
1517792343n
1517792429n
1517792473n
1517792563n
1517792609n
71336257041n
71336257041n
71336257139n
71336257189n
3638149121841n
3638149121893n
3638149121946n
196460052588000n
196460052588055n
196460052588055n
11198222997525633n
11198222997525691n
11198222997525750n
11198222997525810n
11198222997525871n
11198222997525871n
11198222997525997n
11198222997526061n
11198222997526191n
11198222997526191n
11198222997526325n
11198222997526393n
11198222997526531n
11198222997526601n
795073832824398753n
795073832824398753n
795073832824398899n
795073832824398973n
59630537461829934225n
59630537461829934301n
59630537461829934378n
4651181922022734887568n
4651181922022734887647n
4651181922022734887647n
376745735683841525912529n
376745735683841525912611n
376745735683841525912694n
376745735683841525912778n
376745735683841525912863n
376745735683841525912863n
376745735683841525913037n
376745735683841525913125n
376745735683841525913303n
376745735683841525913303n
376745735683841525913485n
376745735683841525913577n
376745735683841525913763n
376745735683841525913857n
35790844889964944961834465n
35790844889964944961834465n
35790844889964944961834659n
35790844889964944961834757n
3543293644106529551221660545n
3543293644106529551221660645n

this is a translation of Kade's answer in C#

Stax, 27 bytes

üµu█QZN/┴¶▬▲▌∙.h├û:╬πa⌠ú-Bq

Run and debug it

Can be improved, definitely, just can't find a way to remove the register usage.

Explanation

1AJDQ_^Y+X"+-*"{]xi^^%{ysl}{d}?F
1                                 push 1
 AJ                               push 10 squared
   D                              repeat the rest of the program 100 times
    Q                             print the current number
     _^                           iteration number
       Y                          store in Y
        +X                        add the two, store in X
          "+-*"{               F  for each of +,-,*
                ]                 convert to string
                 xi^^%            x modulo (iteration count + 2)
                      {   }   ?   if true:
                       ysl        push y and apply the operation
                           { }    else:
                            d     delete the operation
                         
                                 

Perl 6, 62 bytes

1,{((my \v=$_+my \n=++$+1)+n*(v%%2-v%%3))*(v%%4*n||1)}.../645/

Try it online!

REALLY had to work to get my byte count below those of the other non-golf-language solutions.

05AB1E, 24 23 bytes

-1 byte thanks to Kevin Crujissen

¼¾тF=¼¾+©…+-*v®NÌÖi¾y.V

Try it online!

Explanation:

¼¾                        # set the counter to 1, then push 1
  тF                      # repeat the following 100 times
    =                     # print the current number in the sequence
     ¼¾                   # increment the counter
       +                  # add it to the current number
        ©                 # save the result in the register
         …+-*v            # for each of '+', '-', and '*'...
              ®   i       # if the register...
                 Ö        # is divisible by...
               NÌ         # the loop index + 2...
                   ¾y.V   # then apply the current operation

J, 46 bytes

(,{:((]^0=4|+)*(]*0=2|+)++-]*0=3|+)1+#)^:99]1x

Applies the method described in the challenge.

Usage

The extra command (,.~#\) is used to add indices to each value.

   (,.~#\) (,{:((]^0=4|+)*(]*0=2|+)++-]*0=3|+)1+#)^:99]1x
  1                            1
  2                            1
  3                           21
  4                           25
  5                           30
  6                          216
  7                          223
  8                          223
  9                         2169
 10                         2179
 11                         2190
 12                         2202
 13                         2215
 14                         2215
 15                         2245
 16                         2261
 17                         2295
 18                         2295
 19                         2333
 20                         2353
 21                         2395
 22                         2417
 23                        56649
 24                        56649
 25                        56699
 26                        56725
 27                      1533033
 28                      1533061
 29                      1533090
 30                     45993600
 31                     45993631
 32                     45993631
 33                   1517792001
 34                   1517792035
 35                   1517792070
 36                   1517792106
 37                   1517792143
 38                   1517792143
 39                   1517792221
 40                   1517792261
 41                   1517792343
 42                   1517792343
 43                   1517792429
 44                   1517792473
 45                   1517792563
 46                   1517792609
 47                  71336257041
 48                  71336257041
 49                  71336257139
 50                  71336257189
 51                3638149121841
 52                3638149121893
 53                3638149121946
 54              196460052588000
 55              196460052588055
 56              196460052588055
 57            11198222997525633
 58            11198222997525691
 59            11198222997525750
 60            11198222997525810
 61            11198222997525871
 62            11198222997525871
 63            11198222997525997
 64            11198222997526061
 65            11198222997526191
 66            11198222997526191
 67            11198222997526325
 68            11198222997526393
 69            11198222997526531
 70            11198222997526601
 71           795073832824398753
 72           795073832824398753
 73           795073832824398899
 74           795073832824398973
 75         59630537461829934225
 76         59630537461829934301
 77         59630537461829934378
 78       4651181922022734887568
 79       4651181922022734887647
 80       4651181922022734887647
 81     376745735683841525912529
 82     376745735683841525912611
 83     376745735683841525912694
 84     376745735683841525912778
 85     376745735683841525912863
 86     376745735683841525912863
 87     376745735683841525913037
 88     376745735683841525913125
 89     376745735683841525913303
 90     376745735683841525913303
 91     376745735683841525913485
 92     376745735683841525913577
 93     376745735683841525913763
 94     376745735683841525913857
 95   35790844889964944961834465
 96   35790844889964944961834465
 97   35790844889964944961834659
 98   35790844889964944961834757
 99 3543293644106529551221660545
100 3543293644106529551221660645

Brain-Flak 476 466 462 456 446 Bytes

Saved 6 bytes thanks to Wheat Wizard

(((((((())<>()(())()){}){}){}())){}{}){({}[()]<(((({})<>({}())<>))<({}(()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}{(<{}({}<>({})<>)>)}{}>)(({})<({}(()()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}{(<{}({}<>[({})]<>)>)}{}>)({}(()()()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}{(<{}(<>({}))({<({}[()])><>({})<>}{}<><{}>)>)}{}>)}{}

Try it Online!

This is really slow. TIO can't handle the whole 100 numbers (the limit seems to be 22 or 23). So, this example only generates the first 20, but the code would work for 100 as well.

Brief Explanation:

      (())<>                           # push a 1 (the index) and switch stacks 
            (())                       # then push a 1 (the starting number)
((((((          ()()){}){}){}())){}{}) # and a 99 (a counter so that we only print the 
                                       # first 100 numbers)

# repeat until the counter is 0
{
  # pop the counter and push it minus 1 after:
  ({}[()]<
    # hold onto the current number plus the index (leave a copy on the stack to be printed)
    # and increment the index
    (((({})<>({}())<>))<
      # push logical not of (current mod 2)
      ({}(()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}
      # if !(current mod 2) is 1, add the index
      {(<{}({}<>({})<>)>)}{}
    # push the current number back on
    >)
    # hold onto the current number
    (({})<
     # push logical not of (current mod 3)
     ({}(()()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}
     # if !(current mod 3) is 1, then subtract the index
     {(<{}({}<>[({})]<>)>)}{}
    # push the current number back on
    >)
    # push logical not of (current mod 4)
    ({}(()()()())(<()>)){({}[()]<(({}()[({})])){{}(<({}({}))>)}{}>)}({}{}<{}(())>){((<{}{}>))}{}
    # if !(current mod 4) is 1, multiply by the index
    {(<{}(<>({}))({<({}[()])><>({})<>}{}<><{}>)>)}{}
  # put the counter back on
  >)
# loop until done
}
# pop the counter
{}

Haskell, 70 64 bytes

a%b=0^mod a b
n#i|s<-n+i=(s+s%2*i-s%3*i)*i^s%4
scanl1(#)[1..100]

scanl1(#)[1..100] returns the list with the first 100 elements. One byte less if I can stay in the 2^31 range (-> [1..46]).

scanl1 is like foldl1 but collects the intermediate results in a list. The divisibility tests are done via the helper function % which returns 0^0 = 1 if divisible and 0^x = 0 if not.

05AB1E, 34 31 30 bytes

XTnFD,NÌ©+D3L>%_`X®‚sèrŠs-®*+*

Try it online!

Explanation

X                               # initialize stack with 1
 TnF                            # for N in [0 ... 99]
    D,                          # print a copy of top of stack
      NÌ©                       # increase index N by 2 and store in register
         +                      # add this to current value
          D                     # make a copy of the current value
           3L>                  # push the list [2,3,4]
              %                 # take current value mod elements in list
               _                # invert this
                `               # push the elements from the list to stack
                 X®‚sè          # index into list [1,N+2] with the result of mod 4
                      rŠs-      # subtract result of mod 3 from result of mod 2
                          ®*    # multiply by N+2
                            +   # add this to current value
                             *  # multiply current value with the result from index operation

Perl, 75 Bytes

use bigint;$a+=$_,say$a=($a+($a%2?0:$_)-($a%3?0:$_))*($a%4?1:$_)for(1..100)

The code outputs each value on a new line, and computes all 100 values.

JavaScript, 75 63 bytes

for(n=p=0;n++<57;alert(p=p%4?q:q*n))q=(p+=n)%2?p:p+n,q-=p%3?0:n

Another version:

for(n=p=0;n++<57;)alert(p=((p+=n)+(!(p%2)-!(p%3))*n)*(p%4?1:n))

Both stop at index 57 (0-indexed) because that's when the output surpasses JavaScript's safe number size (253 - 1). Turns out a loop is way shorter than a recursive function, even with ES6:

f=(n=0,p=0)=>n++>56?[]:(q=(p+=n)%2?p:p+n,q-=p%3?0:n,[q*=p%4?1:n,...f(n,q)])

This one returns an array of the first 57 elements.

R, 85 82 79 76 72 70 bytes

for(i in 2:56)T[i]=((z=i+T[i-1])+i*(!z%%2)-i*(!z%%3))*`if`(z%%4,1,i);T

ungolfed:

s=1 ## formerly s=1:56, formerly s=1:100
for(i in 2:56){
    z=i+s[i-1]
    s[i]=(z+i*(z%%2<1)-i*(z%%3<1))*(1+(i-1)*(z%%4<1))
}
s

Thanks to @rturnbull for pointing out that I can use (!z%%3) instead of (z%%3<1) to check the moduli, and that the definition of z an happen when it is first used.

Golfed away 3-4 chars by abusing vector extension: the answer originally started s=1:56... but we don't need to do that, the length of s will be extended as needed.

Saved 3 more bytes by replacing the last condition with a call to the "if" function (yes, it's a proper function in R!)

Saved 4 more bytes by replacing s with T, which is a builtin equal to TRUE which is also equal to 1. I realised it at the same time as @rturnbull (honest!)

This does suffer from some numerical issues once we exceed 2^52, but there is nothing I can do about that --- R can only use double types for numbers larger than 2^31-1, but they store integers up to 2^52 exactly. Thus, I am allowed to only output the first 56 terms (the last term which is "right") which saves one byte over the 100-length case.

Here's the output from the 56-length version:

    > for(i in 2:56){z=i+T[i-1];T[i]=(z+i*(!z%%2)-i*(!z%%3))*`if`(z%%4,1,i)};T
 [1]               1               1              21              25              30             216
 [7]             223             223            2169            2179            2190            2202
[13]            2215            2215            2245            2261            2295            2295
[19]            2333            2353            2395            2417           56649           56649
[25]           56699           56725         1533033         1533061         1533090        45993600
[31]        45993631        45993631      1517792001      1517792035      1517792070      1517792106
[37]      1517792143      1517792143      1517792221      1517792261      1517792343      1517792343
[43]      1517792429      1517792473      1517792563      1517792609     71336257041     71336257041
[49]     71336257139     71336257189   3638149121841   3638149121893   3638149121946 196460052588000
[55] 196460052588055 196460052588055

Batch, 110 bytes

@set n=0
@for /l %%i in (1,1,46)do @set/an=((n+=%%i)+(!(n%%2)-!(n%%3))*%%i)*(~-%%i*!(n%%4)+1)&call echo %%n%%

Uses @ETHproductions' formula, but tweaked slightly because Batch doesn't have ?:. Batch uses 32-bit signed integers so the loops stops at 46.

Python 2, 76 Bytes

Pretty standard implementation, I think using an exec statement rather than a while loop saved 2 bytes or so. A recursive method may be shorter, I imagine xnor will pop up soon ;)

n=1
f=1
exec'print f;n+=1;d=f+n;f=(d+n*(d%2<1)-n*(d%3<1))*[1,n][d%4<1];'*100

If I used the updates that TheNumberOne figured out, I would be at 69 bytes (but then I would be copying)

n=f=1;exec'print f;n+=1;d=f+n;f=(d+n-n*(d%2+(d%3<1))*n**(d%4<1);'*100

Output:

1
1
21
25
30
216
223
223
2169
2179
2190
2202
2215
2215
2245
2261
2295
2295
2333
2353
2395
2417
56649
56649
56699
56725
1533033
1533061
1533090
45993600
45993631
45993631
1517792001
1517792035
1517792070
1517792106
1517792143
1517792143
1517792221
1517792261
1517792343
1517792343
1517792429
1517792473
1517792563
1517792609
71336257041
71336257041
71336257139
71336257189
3638149121841
3638149121893
3638149121946
196460052588000
196460052588055
196460052588055
11198222997525633
11198222997525691
11198222997525750
11198222997525810
11198222997525871
11198222997525871
11198222997525997
11198222997526061
11198222997526191
11198222997526191
11198222997526325
11198222997526393
11198222997526531
11198222997526601
795073832824398753
795073832824398753
795073832824398899
795073832824398973
59630537461829934225
59630537461829934301
59630537461829934378
4651181922022734887568
4651181922022734887647
4651181922022734887647
376745735683841525912529
376745735683841525912611
376745735683841525912694
376745735683841525912778
376745735683841525912863
376745735683841525912863
376745735683841525913037
376745735683841525913125
376745735683841525913303
376745735683841525913303
376745735683841525913485
376745735683841525913577
376745735683841525913763
376745735683841525913857
35790844889964944961834465
35790844889964944961834465
35790844889964944961834659
35790844889964944961834757
3543293644106529551221660545
3543293644106529551221660645

Python 3, 82 78 76 74 72 bytes

i=s=1
exec('print(s);i+=1;s+=i;s=(s+i-i*(s%2+(s%3<1)))*i**(s%4<1);'*100)

Output:

1
1
21
25
30
216
223
223
2169
2179
2190
2202
2215
2215
2245
2261
2295
2295
2333
2353
2395
2417
56649
56649
56699
56725
1533033
1533061
1533090
45993600
45993631
45993631
1517792001
1517792035
1517792070
1517792106
1517792143
1517792143
1517792221
1517792261
1517792343
1517792343
1517792429
1517792473
1517792563
1517792609
71336257041
71336257041
71336257139
71336257189
3638149121841
3638149121893
3638149121946
196460052588000
196460052588055
196460052588055
11198222997525633
11198222997525691
11198222997525750
11198222997525810
11198222997525871
11198222997525871
11198222997525997
11198222997526061
11198222997526191
11198222997526191
11198222997526325
11198222997526393
11198222997526531
11198222997526601
795073832824398753
795073832824398753
795073832824398899
795073832824398973
59630537461829934225
59630537461829934301
59630537461829934378
4651181922022734887568
4651181922022734887647
4651181922022734887647
376745735683841525912529
376745735683841525912611
376745735683841525912694
376745735683841525912778
376745735683841525912863
376745735683841525912863
376745735683841525913037
376745735683841525913125
376745735683841525913303
376745735683841525913303
376745735683841525913485
376745735683841525913577
376745735683841525913763
376745735683841525913857
35790844889964944961834465
35790844889964944961834465
35790844889964944961834659
35790844889964944961834757
3543293644106529551221660545
3543293644106529551221660645

Suggestions are welcome!

C#, 120 Bytes

Just as no sane person would golf in Java, no sane person should golf in C#! But screw that, I wanted to see what I can do. The 1M casts f to be a decimal which has enough precision for this answer without me having to write decimal. Also, the in-place incrementing saves some bytes on my Python answer. in the end it is still 50 bytes longer.

void k(){int n=1;var f=1M;while(n<101){Console.WriteLine(f);var d=++n+f;f=(d+n*((d%2<1?1:0)-(d%3<1?1:0)))*(d%4<1?n:1);}}

Here's the more readable (and runnable) version:

using System;
class P
{
    static void Main(string[]a) 
    {
        int n = 1;
        var f = 1M;
        while (n < 101) 
        {
            Console.WriteLine(f);
            var d = ++n + f;
            f = (d + n * ((d % 2 < 1 ? 1 : 0) - (d % 3 < 1 ? 1 : 0))) * (d % 4 < 1 ? n : 1);
        }
        Console.Read();
    }
}

Java 7, 316 bytes

import java.math.*;String c(){String r="";BigInteger t=BigInteger.ONE,x,p;for(int i=2;i<102;){r+=t+" ";p=(t=t.add(x=new BigInteger(i+++"")));t=x(p,2)?t.add(x):t;t=x(p,3)?t.subtract(x):t;t=x(p,4)?t.multiply(x):t;}return r;}boolean x(BigInteger p,int i){return p.mod(new BigInteger(i+"")).compareTo(BigInteger.ONE)<0;}

Ungolfed & test code:

Try it here.

import java.math.*;
class M{
  static String c(){
    String r = "";
    BigInteger t = BigInteger.ONE,
               x,
               p;
    for(int i = 2; i < 102;){
      r += t+" ";
      p = (t = t.add(x = new BigInteger(i++ + "")));
      t = x(p, 2)
           ? t.add(x)
           : t;
      t = x(p, 3)
           ? t.subtract(x)
           : t;
      t = x(p, 4)
           ? t.multiply(x)
           : t;
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c());
  }

  static boolean x(BigInteger p, int i){
    return p.mod(new BigInteger(i+"")).compareTo(BigInteger.ONE) < 0;
  }
}

Output:

1 1 21 25 30 216 223 223 2169 2179 2190 2202 2215 2215 2245 2261 2295 2295 2333 2353 2395 2417 56649 56649 56699 56725 1533033 1533061 1533090 45993600 45993631 45993631 1517792001 1517792035 1517792070 1517792106 1517792143 1517792143 1517792221 1517792261 1517792343 1517792343 1517792429 1517792473 1517792563 1517792609 71336257041 3424140340272 3424140340321 3424140340371 3424140340473 3424140340525 3424140340631 3424140340631 3424140340741 3424140340797 3424140340911 3424140340969 202024280124133 202024280124193 202024280124315 202024280124377 12727529647843689 814561897462000192 52946523335030016705 52946523335030016771 52946523335030016905 52946523335030016973 52946523335030017111 52946523335030017111 52946523335030017253 52946523335030017253 52946523335030017399 52946523335030017473 3970989250127251321725 301795183009671100456876 301795183009671100456953 301795183009671100457031 301795183009671100457110 301795183009671100457270 301795183009671100457351 301795183009671100457433 25049000189802701337980717 25049000189802701337980801 25049000189802701337980971 25049000189802701337981057 2179263016512835016404367097 191775145453129481443584312280 17067987945328523848479003800841 1536118915079567146363110342083790 1536118915079567146363110342083790 1536118915079567146363110342083974 1536118915079567146363110342083974 144395178017479311758132372155911228 13717541911660534617022575354811575685 13717541911660534617022575354811575781 13717541911660534617022575354811575975 13717541911660534617022575354811576073 1358036649254392927085234960126346050829