Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Why code run not correctly Post 302670569 by FUTURE_EINSTEIN on Thursday 12th of July 2012 08:09:36 AM
Old 07-12-2012
Quote:
Originally Posted by guruprasadpr
Hi

The closing brackets were placed at the wrong places:


Code:
echo "Type in a positive number"
read X
I=2
while [ $X>$I ]
do
    if [ $(($X%$I)) == 0 ]
    then
    echo "It is not prime"
    break
    else
    if [ $(($X-$I)) == 1 ]
    then
    echo "It is  prime"
    break
    else
    I=$(( $I + 1))
    fi
    fi
done

Thanks for answering I tried to remove all the spaces in arithmetic expressions but still it generates wrong answer
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run perl command in script[solved]

Hi all, When I put the Perl command in a script, I got error. system("perl -pi -e 's@words@words@g' myFile"); The error is: Unrecognized character \x8A; marked by <-- HERE after دت مد�<-- HERE near column 15 at -e line 1. Thanks in advance. ---------- Post updated at 06:30 AM... (0 Replies)
Discussion started by: Lham
0 Replies

2. Shell Programming and Scripting

run command with ssh[solved]

Hi all, Is it possible to make this possible ? $ echo $SKY_HOME /var/sink/SKY $ echo $SKY_HOME /home/smily/SKY $ ssh root@xyz "echo $SKY_HOME" root@xyz 's password: ****** /home/smily/SKY wrong output I was expecting the output as /var/sink/SKY (3 Replies)
Discussion started by: linuxadmin
3 Replies

3. Shell Programming and Scripting

run shell script under nohup directly [solved]

Hi, i am not able to run the loop in nohup directly. nohup 'for i in $(seq 10); do echo $i;./mscript.sh $i; done' can some one help me how to run this directly in nohup? ---------- Post updated 03-15-12 at 12:20 AM ---------- Previous update was 03-14-12 at 11:59 PM ---------- From... (0 Replies)
Discussion started by: johninweb
0 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Cron - job to run every 3rd Friday of the month only

Hi Expert Please help me to set a cron job schedule, Ihave a job that run every 3rd Friday of the month at 1030am. I tried to set up like this, but the job still runs every friday at 1030am. I want the job to run every 3rd Friday of the month at 1030am only 30 10 15,16,17,18,19,20,21... (2 Replies)
Discussion started by: kaibiganmi
2 Replies

5. UNIX for Advanced & Expert Users

[SOLVED] Code does not run when assigned to a variable

I am more of a newbie, but wanted to post this in this forum as I was afraid no one would look at it in unix forums as it concerns shell scripting. I have a shell script that now runs fine with the exclusion of one line: x=`su nbadmin -c "ssh -t servery /usr/openv/netbackup/bin/bplist -C... (7 Replies)
Discussion started by: newbie2010
7 Replies

6. Shell Programming and Scripting

[Solved] Run multiple commands in invoked program

Hi, I have coded a program in Haskell using the compiler Hugs and the program requires multiple commands (with parameters) to be entered into it, it then outputs the result of its execution. I need to test a lot of different options (i.e. the parameters) so it would be obvious to automate the... (0 Replies)
Discussion started by: tz742
0 Replies

7. Homework & Coursework Questions

Cannot correctly connect multi-stage C command pipe (among others) (FYI: a lot of code)

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: We are supposed to write a C program that parses a command line, separates it into each command (further... (5 Replies)
Discussion started by: kowit010
5 Replies

8. Shell Programming and Scripting

[Solved] Help understanding this code!!

Hi guys, I am still learning awk and much apprecated to shed some light on the following: the questions asked is below! { total = i = 0 do { ++i total += $i } while ( total <= 100 ) print i, ":", total } File used: cat test.do 45 25 60 20 10 105 50 40 33 5 9 67 108 3 5 4 (2 Replies)
Discussion started by: Apollo
2 Replies

9. UNIX for Beginners Questions & Answers

When I run the code yesterday I am getting output,when I run same code today I am getting error?

If run the below code today its creating all directory and getting output files,I f run same code tomorrow I am getting error. can any one give suggestion to sortout this error. OSError: no such file or directory : '062518'My code looks like this import paramiko import sys import os ... (8 Replies)
Discussion started by: haribabu2229
8 Replies
GMP_PROB_PRIME(3)							 1							 GMP_PROB_PRIME(3)

gmp_prob_prime - Check if number is ";probably prime"

SYNOPSIS
int gmp_prob_prime (GMP $a, [int $reps = 10]) DESCRIPTION
The function uses Miller-Rabin's probabilistic test to check if a number is a prime. PARAMETERS
o $a - The number being checked as a prime. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. o $reps - Reasonable values of $reps vary from 5 to 10 (default being 10); a higher value lowers the probability for a non-prime to pass as a "probable" prime. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. RETURN VALUES
If this function returns 0, $a is definitely not prime. If it returns 1, then $a is "probably" prime. If it returns 2, then $a is surely prime. EXAMPLES
Example #1 gmp_prob_prime(3) example <?php // definitely not a prime echo gmp_prob_prime("6") . " "; // probably a prime echo gmp_prob_prime("1111111111111111111") . " "; // definitely a prime echo gmp_prob_prime("11") . " "; ?> The above example will output: 0 1 2 PHP Documentation Group GMP_PROB_PRIME(3)
All times are GMT -4. The time now is 03:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy