1. Write the syntax definitions of the following objects: (a) Natural number (1, 2, 3, …)
(b) Unsigned integer (0, 1, 2, 3, …)
(c) Integer (…, -2, -1, 0, 1, 2, …)
(d) Odd number (…, -3, -1, 1, 3, …) (e) Even number (…, -4, -2, 0, 2, 4, …) (f) Integer divisible by 5 (…, -10, -5, 0, 5, 10, …)
Solve each problem from (a) to (f)using EBNF, syntax diagrams, and the parenthetic notation.
A) Natural Number(1,2,3,....)
<Natural number> ::= <digit exclude zero> | <Natural number> <digit>
<digit exclude zero> ::= 1|2|3|4|5|6|7|8|9
<digit> ::= 0|1|2|3|4|5|6|7|8|9
b) Unsigned Integer(0,1,2,3,...)
<Unsigned integer>::=<digit>|<unsigned integer><digit>
c) Integer (...., -2,-1,0,1,2,...)
<Integer> ::= <sign> <Unsigned integer>
<sign> ::= +|-|<empty>
<empty> ::=
d) Odd number (..., -3,-3,1,3, ....)
<Odd number> ::= <sign> <odd value>
<odd value> ::= <prefix><odd suffix>
<prefix> ::=<empty>|<prefix><digit>
<odd suffix>::=1|3|5|7|9
e) Even number (...,-4,-2,0,2,4, ...)
<Even number>::=<sign><even value>
<even value>::=<prefix><even suffix>
<prefix>::=<empty>|<prefix><digit>
<even suffix>::=0|2|4|6|8
f)Integer divisible by five(...,-10,-5,0,5,10,...)
<Integer divisible by five>::=<sign> <value divisible by five>
<value divisible by five>::=<prefix><suffix divisible by five>
Note:-
If you have any doubts then comment below i am very happy to solve your doubts please don't give negative reviews it's very important for me please thumbs up me
Thank you
1. Write the syntax definitions of the following objects: (a) Natural number (1, 2, 3, …)...
How to solve it using Python?
5. Write a function called no_squares which takes an input parameter N, a positive integer, and returns: 1 if N is not divisible by a square and has an even number of prime factors -1 if N is not divisible by a square and has an odd number of prime factors 0 if N is divisible by a square For example, no-squares (10) returns 1 (since 10 = 2x5), no-squares (30) returns-1 (since 30...
2. Write negations of the following statements: a. Jim is inside and tome is at the Pool. b. Jim is taller or Tom is shorter. c. If this program worked then the data is in order. d. For all integers n, If n is divisible by 15 then n is divisible by 3 and n is divisible by 5. e. There exist an integer n such that n is even and n' +3n-1 is odd. Page 1 of S
Definition of Even: An integer n ∈ Z is even if there exists an integer q ∈ Z such that n = 2q. Definition of Odd: An integer n ∈ Z is odd if there exists an integer q ∈ Z such that n = 2q + 1. Use these definitions to prove only #5: 2. Prove that zero is even. 3. Prove that for every natural number n ∈ N, either n is even or n is odd. 4....
I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....
5) Write TOY AL subprogram that implements the following subprogram interface: Label: SumEven On entry: Register $1 is the return address of the caller. Register $A is the address in memory of an array A. Register $s is the size of the array A. On exit: Register $F is the sum of the entries of A that are even (divisible by 2) No values in memory have changed. Any of the registers may have changed value. Hint: The TOY assembly...
2. Give the asymptotic running time of each the following functions in e notation. That is, write down a recurrence relation for each recursive function below and solve it. Show your work def Pow(x, n): 2 if n-0: 3 return 1 end 5 e f Pow(x, [n/2]) 1 # n is even if n % 2-0: 9 return f f 10 end #nis odd 12return r*f*.f 13 end
1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3. Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...
Write a C program to do the following 1) request user to enter 10 integer into an array 2) sort the array in ascending order 3) display the sorted array 4) count the number of odd and even number in the array and print out the result 5) add the value of the odd number and even number and calculate the average of the odd and even number. display the result 6) write function addNumber() to add all the number...
Translate the following English sentences into statements of predicate calculus. a. All programmers enjoy discrete mathematics b. Some integers are not odd c. Every integer that is divisible by 2 is even d. There exists a natural number that is not a positive integer Refer to the statements of predicate calculus you provided for part 1. Write the negation of each of those statements. .
Let wE S7 be a permutation which rearranges 7 objects as follows, showing the result on the lower line 2 3 4 6 7 5 5 4 2 7 6 1 3 a) Express was a product of disjoint cycles representing how each object moves Is w an even permutation, or an odd permutation? What is its order? products of disjoint cycles b) Calculate w3, w5 and w' 2 as c) Does there exist T E S7 for which T-lwr...