15,997,068 members
1.00/5 (1 vote)
See more:
```<pre>#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
static const int64_t a = 93113;
static const int64_t s = 35271;
static const int64_t w = 19094;
static int64_t my_data[] = {w, 48275, 31328, 57769, a, s};
static const int N = sizeof(my_data)/size of(*my_data);
static bool f(int q. int64_t y)
{
if(q<N){
if((q%2)==0)
f(++q, y);
else f(q+1, y+my_data[q]);
}else return y==188129;
}```

What I have tried:

I tried bottom up approach and tried to solve mathematically but didn't get all the values correct.
Posted
Updated 28-Apr-23 4:11am
jeron1 27-Apr-23 15:40pm
Can't imagine that this will compile, and not sure what the question is but there should be a comma instead of a period in the following;
static bool f(int q. int64_t y) // <== should have comma

Also there is a space between 'size' and 'of' in the following;
static const int N = sizeof(my_data)/size of(*my_data);
Rick York 27-Apr-23 16:01pm
One other thing, not all control paths return a value in f. If q is less than N then nothing is returned.

## Solution 1

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Work from the result you need backwards - the idea is to teach you to understand code and how it works: that wouldn't happen if we solve it for you!

I'd suggest that you throw that away, and start by writing your own code to solve the problem you were set instead. That way, you start developing the skills you are going to need for future assignments on simple tasks - and if you don;t, then the more complex tasks you are set later which assume that you have the rudiments of such skills will be completely beyond you ... and then you fail the course.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

## Solution 2

Have a look at your compiler output. If I try to compile your code (`gcc -Wall program.c`), the compiler outputs:
```program.c:8:38: error: ‘size’ undeclared here (not in a function); did you mean ‘size_t’?
8 | static const int N = sizeof(my_data)/size of(*my_data);
|                                      ^~~~
|                                      size_t
program.c:8:43: error: expected ‘,’ or ‘;’ before ‘of’
8 | static const int N = sizeof(my_data)/size of(*my_data);
|                                           ^~
program.c:9:8: error: unknown type name ‘bool’
9 | static bool f(int q. int64_t y)
|        ^~~~
program.c:9:20: error: expected ‘;’, ‘,’ or ‘)’ before ‘.’ token
9 | static bool f(int q. int64_t y)
|                    ^
program.c:8:18: warning: ‘N’ defined but not used [-Wunused-const-variable=]
8 | static const int N = sizeof(my_data)/size of(*my_data);```

The error messages give precious hints.

v2