Sponsored Content
Homework and Emergencies Homework & Coursework Questions Sum of even numbers from 0 to 100 script Post 303031640 by Scrutinizer on Sunday 3rd of March 2019 07:03:47 AM
Old 03-03-2019
Instead of incrementing the counter by 1 in the loop and then testing if it even, you could also increment the counter by 2 at every iteration. That way you would not need to test if it is even if the initial value of the counter is even.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to sum numbers in column

Hi, i want to sum all nubers in one column. Example: 12.23 11 23.01 3544.01 I'm trying to do this in awk, but it doesn't work properly. Seems like awk is summing only integers, for example: 12 11 23 3544 It cuts off numbers after dot. I used this command: akw /text/ file.txt |nawk... (1 Reply)
Discussion started by: iahveh
1 Replies

2. Shell Programming and Scripting

sum numbers from stdout

hello im looking for short way to sum numbers from stdout the way i found to do it is to long for me i wander if there is shorter way to do it ok it 2 stage action this will make the list of number in to file sum.txt grep -c include *.c | awk '{l=split($0,a,":");print a;}' > sum.txt this... (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Shell script to find the sum of first n Fibonacci numbers

pls give me the solution for this i need it for my exam pls pls pls Shell script to find the sum of first n Fibonacci numbers (1 Reply)
Discussion started by: Kshitija
1 Replies

4. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

5. Shell Programming and Scripting

Finding the sum of two numbers

cat *.out |grep "<some text>" | awk '{print $6}' For ex,This will reutrn me 11111 22222 is it possible to add these two numbers in the above given command itself?I can write this to a file and find the sum. But I prefer to this calculation in the above given line itself. Any... (3 Replies)
Discussion started by: prasperl
3 Replies

6. Shell Programming and Scripting

getting the sum of numbers

I basically have a file where I had to do a bunch of greps to get a list of numbers example: a file called numbers.txt 10000 10000 superman 10000 batman 10000 10000 grep '100' * | 10000 10000 10000 10000 10000 (2 Replies)
Discussion started by: zerofire123
2 Replies

7. Shell Programming and Scripting

Sum Numbers from different files

Hi All, I need to print the sum of numbers from different files. Input files: file1.out 10 20 30 file2.out 10 20 30 (5 Replies)
Discussion started by: saint2006
5 Replies

8. Shell Programming and Scripting

Script Shell: Count The sum of numbers in a file

Hi all; Here is my file: V1.3=4 V1.4=5 V1.1=3 V1.2=6 V1.3=6 Please, can you help me to write a script shell that counts the sum of values in my file (4+5+3+6+6) ? Thank you so much for help. Kind regards. (3 Replies)
Discussion started by: chercheur111
3 Replies

9. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies

10. UNIX for Beginners Questions & Answers

Sum even numbers from 1 to 100

I need help with this assignment. I'm very new to using UNIX/LINUX, and my only previous experience with programing anything is using python. We are writing scripts using vim, and this one I'm stumped on. "Write a shell script that finds and display the sum of even positive integers from 0 to... (5 Replies)
Discussion started by: Nastybutler
5 Replies
DSA_generate_parameters(3SSL)					      OpenSSL					     DSA_generate_parameters(3SSL)

NAME
DSA_generate_parameters - generate DSA parameters SYNOPSIS
#include <openssl/dsa.h> DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len, int *counter_ret, unsigned long *h_ret, void (*callback)(int, int, void *), void *cb_arg); DESCRIPTION
DSA_generate_parameters() generates primes p and q and a generator g for use in the DSA. bits is the length of the prime to be generated; the DSS allows a maximum of 1024 bits. If seed is NULL or seed_len < 20, the primes will be generated at random. Otherwise, the seed is used to generate them. If the given seed does not yield a prime q, a new random seed is chosen and placed at seed. DSA_generate_parameters() places the iteration count in *counter_ret and a counter used for finding a generator in *h_ret, unless these are NULL. A callback function may be used to provide feedback about the progress of the key generation. If callback is not NULL, it will be called as follows: o When a candidate for q is generated, callback(0, m++, cb_arg) is called (m is 0 for the first candidate). o When a candidate for q has passed a test by trial division, callback(1, -1, cb_arg) is called. While a candidate for q is tested by Miller-Rabin primality tests, callback(1, i, cb_arg) is called in the outer loop (once for each witness that confirms that the candidate may be prime); i is the loop counter (starting at 0). o When a prime q has been found, callback(2, 0, cb_arg) and callback(3, 0, cb_arg) are called. o Before a candidate for p (other than the first) is generated and tested, callback(0, counter, cb_arg) is called. o When a candidate for p has passed the test by trial division, callback(1, -1, cb_arg) is called. While it is tested by the Miller- Rabin primality test, callback(1, i, cb_arg) is called in the outer loop (once for each witness that confirms that the candidate may be prime). i is the loop counter (starting at 0). o When p has been found, callback(2, 1, cb_arg) is called. o When the generator has been found, callback(3, 1, cb_arg) is called. RETURN VALUE
DSA_generate_parameters() returns a pointer to the DSA structure, or NULL if the parameter generation fails. The error codes can be obtained by ERR_get_error(3). BUGS
Seed lengths > 20 are not supported. SEE ALSO
dsa(3), ERR_get_error(3), rand(3), DSA_free(3) HISTORY
DSA_generate_parameters() appeared in SSLeay 0.8. The cb_arg argument was added in SSLeay 0.9.0. In versions up to OpenSSL 0.9.4, callback(1, ...) was called in the inner loop of the Miller-Rabin test whenever it reached the squaring step (the parameters to callback did not reveal how many witnesses had been tested); since OpenSSL 0.9.5, callback(1, ...) is called as in BN_is_prime(3), i.e. once for each witness. 1.0.1e 2013-02-11 DSA_generate_parameters(3SSL)
All times are GMT -4. The time now is 11:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy