C
C#•3y ago
sns

Someone please figure out this sequence

2, -1, 8, -4, 26, -16, 98, ...
28 Replies
sns
snsOP•3y ago
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]);
sns
snsOP•3y ago
my guy
hanu
hanu•3y ago
😌
sns
snsOP•3y ago
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
sns
snsOP•3y ago
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?
sns
snsOP•3y ago
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
sns
snsOP•3y ago
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
sns
snsOP•3y ago
sns
snsOP•3y ago
Tried to translate So, no I don't need to literally write that lol
hanu
hanu•3y ago
how is this possible
sns
snsOP•3y ago
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
sns
snsOP•3y ago
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?
sns
snsOP•3y ago
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
sns
snsOP•3y ago
Imho, it's clear that after 98 we'd have a -64
hanu
hanu•3y ago
mathematicians will get upset lol
sns
snsOP•3y ago
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
sns
snsOP•3y ago
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?

Did you find this page helpful?