Skip to main content
added 118 characters in body
Source Link
Billywob
  • 3.5k
  • 13
  • 16

R, 56 56 49 bytes

n=scan();x=2;for(i in 1:n){x=c(x,prod(x)+1)};cat(x[n+1]) 

Ungolfed:

n=scan() # Take input n x=2 # Initialize sequence to 2 for(i in 1:n){ x=c(x,prod(x)+1) # Append the product of the previous numbers + 1 } cat(x[n+1]) # Print the nth + 1 number in seq 

Slightly golfed thanks to @Frédéric:

n=scan();x=2;for(i in 1:n)x=c(x,prod(x)+1);x[n+1] 

R, 56 bytes

n=scan();x=2;for(i in 1:n){x=c(x,prod(x)+1)};cat(x[n+1]) 

Ungolfed:

n=scan() # Take input n x=2 # Initialize sequence to 2 for(i in 1:n){ x=c(x,prod(x)+1) # Append the product of the previous numbers + 1 } cat(x[n+1]) # Print the nth + 1 number in seq 

R, 56 49 bytes

n=scan();x=2;for(i in 1:n){x=c(x,prod(x)+1)};cat(x[n+1]) 

Ungolfed:

n=scan() # Take input n x=2 # Initialize sequence to 2 for(i in 1:n){ x=c(x,prod(x)+1) # Append the product of the previous numbers + 1 } cat(x[n+1]) # Print the nth + 1 number in seq 

Slightly golfed thanks to @Frédéric:

n=scan();x=2;for(i in 1:n)x=c(x,prod(x)+1);x[n+1] 
Source Link
Billywob
  • 3.5k
  • 13
  • 16

R, 56 bytes

n=scan();x=2;for(i in 1:n){x=c(x,prod(x)+1)};cat(x[n+1]) 

Ungolfed:

n=scan() # Take input n x=2 # Initialize sequence to 2 for(i in 1:n){ x=c(x,prod(x)+1) # Append the product of the previous numbers + 1 } cat(x[n+1]) # Print the nth + 1 number in seq