473,379 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Recursivity

Well I need to implement a recustivity function to calculate the Rc value of a vactor Rcon, whinc is define like this: Rcon[i] = (RC[i]; 0; 0; 0), each element of the vector is one byte. And the only non-zero byte in the round constants obeys the following recursive formula: So I only need to calculate Rc[i], according to the following formula:

RC[1] = 1
RC[j] = 2 * RC[j - 1]

for example, if i = 1, then Rc[1] = 1; if i = 2, then Rc[2] = 2, if i = 3, then Rc[3] = 4, and so on,

Thanks for your help.
Sep 6 '06 #1
1 1910
Try the following program....


#include<stdio.h>

int rc(int);

int main()
{
int num;
printf("Enter a number ");
scanf("%d",&num);
printf("Result is %d\n",rc(num));
return 0;
}




int rc(int num)
{
if(num == 1)
return 1;

return(2*rc(num-1));
}
Sep 6 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Claude ANIMO | last post by:
Hello, I am in the process of writing an XML analyzer. In order to build the tree structure I intensivly rely on recursivity. The depths are not excessive. With no more than 10 recursive calls...
1
by: pepete | last post by:
Hi, I am trying to do a script that is must print a tree of object (my objects are some comments). For more details, a "comment" is an object which can be at the top of the tree (father), or...
4
by: Allen | last post by:
Hi all, What are some different approaches to dealing with stack overflows in C++? I'm especially interested in approaches concerned with speed for infrequent overflows. -- Best wishes,...
2
by: JellyON | last post by:
Hi. I'm a little bit lost trying to insert a setTimeout() for recursive call containing string and numeric parameters. Here is a generic example of what I would like to succeed to do : ...
8
by: Brian L. Troutwine | last post by:
I've got a problem that I can't seem to get my head around and hoped somebody might help me out a bit: I've got a dictionary, A, that is arbitarily large and may contains ints, None and more...
13
by: Lad | last post by:
If I have a list Mylist= I can print it for i in Mylist: print i and results is 1
2
kadghar
by: kadghar | last post by:
Many people asks if there is a way to write a mathematical expression, writen as a string in a text box, so they can do something like: sub something_click() textbox2.text=eval(textbox1.text)...
29
by: curiously enough | last post by:
I am having trouble making this recursive C function work for square matrices of size greater than 3 rows and columns. #include<stdio.h> #include<conio.h> #include<math.h> int M; float...
7
by: Extremity | last post by:
Hi, I am taking a intro to C++ course so my knowledge base only limits to areas such as if/else, functions, and recursions. We are creating a program which will determine the probability of Poker...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.