Someone please figure out this sequence

2, -1, 8, -4, 26, -16, 98, ...
28 Replies
snowy | switching accounts
Index 0: 2 Index 1: -1 .... this 98 is a pain Basically, I know this piece of a sequence: 2, -1, 8, -4, 26, -16, 98, ... And I have to find the value in the input index. So, if anyone inputs 0, it returns 2 If anyone inputs 1, it returns -1 And so on... My uni teacher lol I broke it down to this, although it is python, let me send
if i == 0:
print(2)
elif i%2 == 0:
print(2**i + 2**(i-1) + 2)
else:
print(2**(i-1)*-1)
if i == 0:
print(2)
elif i%2 == 0:
print(2**i + 2**(i-1) + 2)
else:
print(2**(i-1)*-1)
** = ^ in c#
hanu
hanu•3y ago
int[] array = { /* somehow defined */ };
int index = int.Parse(Console.ReadLine());
Console.WriteLine(array[index]);
int[] array = { /* somehow defined */ };
int index = int.Parse(Console.ReadLine());
Console.WriteLine(array[index]);
snowy | switching accounts
my guy
hanu
hanu•3y ago
😌
snowy | switching accounts
omegalul there isn't much more to say It's really just that
hanu
hanu•3y ago
i'm pretty sure the professor didn't want you to analyze the sequence
snowy | switching accounts
get an index as input and return the value in that position on this given sequence The "homework" is literally that lol
hanu
hanu•3y ago
analyze?
snowy | switching accounts
I'll translate
hanu
hanu•3y ago
i can make tons of different sequences that start with 2, -1, 8, -4, 26, -16, 98, ... let's say, as many as the number of real numbers
snowy | switching accounts
Below, we have a list of a few sequences of numbers. Each sequence number has an index, starting on 0. Write a programr that reads the input as the index i of a number, and show in the screen the number of the sequence that is in the i position
Below, we have a list of a few sequences of numbers. Each sequence number has an index, starting on 0. Write a programr that reads the input as the index i of a number, and show in the screen the number of the sequence that is in the i position
snowy | switching accounts
Tried to translate So, no I don't need to literally write that lol
hanu
hanu•3y ago
how is this possible
snowy | switching accounts
Wym? We have to believe that there is a logic behind that sequence, and find out what the logic is For example, 0, 1, 2, 3, 4, 5, 6, ...
hanu
hanu•3y ago
literally how can i find 10th number when just 7 numbers and nothing else are given
snowy | switching accounts
It's clear that I'd have to simply Console.WriteLine(input)
hanu
hanu•3y ago
is that clear? why 9 cannot come after 6?
snowy | switching accounts
Yes, that's what anyone with a basic logical thinking would deduct by seeing this piece of the sequence holy fuck Well, not much more than that We'd have to try and deduct the logic behind it
hanu
hanu•3y ago
... that doesn't make sense
snowy | switching accounts
Imho, it's clear that after 98 we'd have a -64
hanu
hanu•3y ago
mathematicians will get upset lol
snowy | switching accounts
Idk if there is a math formula for this sequence Most likely that there isn't
hanu
hanu•3y ago
for instance, i can set the sequence a[n] = \sum_{i=1}^7 c_i a[n-i] for n > 6 for arbitrary values c_1, ..., c_7 and it's valid
snowy | switching accounts
I do feel like this is the way it should be at least, or something near to that btw how did you do that
hanu
hanu•3y ago
(solving a linear simultaneous equations)
hanu
hanu•3y ago
how about this for 0, 1, 2, ..., 6
hanu
hanu•3y ago
1,-1,1,...,-1?
Want results from more Discord servers?
Add your server