Question

In: Computer Science

Thank you all. my other code is working fine. It was my IDE issue. This is...

Thank you all. my other code is working fine. It was my IDE issue.

This is the new code i am writing for the below question. please help as you always do:

a=int(input('Input a: '));
b=int(input('Input b: '));
c=int(input('Input c: '));
r=int(input('Input r: '));
s=int(input('Input s: '));
t=int(input('Input t: '));
x=2;
min_rst = min(r,s,t);
while(1):
if((x-a)%r==0):
if((x-b)%s==0):
if((x-c)%t==0):
break;
x=x+1;
print('The required number is: ',x);

Questions:

Write a Python program called crt.py
that finds the value of x that satisfies a system of congruencies of the form:
x ≡ a (mod r)
x ≡ b (mod s)
x ≡ c (mod t)
where a, b, and c are integers; and r, s, and t are pairwise relatively prime positive
integers (i.e., gcd(r, s) = gcd(s, t) = gcd(r, t) = 1). Your program
prompts the user for the values of a, b, c, r, s, and t, and outputs the value of
x that satisfies the system of congruencies. Hint: see the NumPy Ntheory class
reference: http://docs.sympy.org/dev/modules/ntheory.html. Submit your Python
source code crt.py.

Thank you

Solutions

Expert Solution

Solution:

a = int(input('Input a: '))
b = int(input('Input b: '))
c = int(input('Input c: '))
r = int(input('Input r: '))
s = int(input('Input s: '))
t = int(input('Input t: '))
x = 2
min_rst = min(r, s, t)
while (1):
    if (x - a) % r == 0 and (x - b) % s == 0 and (x - c) % t == 0:
        break
    x = x + 1
print('The required number is: ', x)

Output:


Related Solutions

My code is working fine but after selecting an option and at the end I want...
My code is working fine but after selecting an option and at the end I want user could enter another option again without going back to menu. However, in my code when I enter another option, it prints the whole menu again then I can select option.Could anyone help me on that? #include "stdafx.h" #include #include #include using namespace std; const double pi = 3.14159265358979323846; const double deg_to_rad = (pi / 180); int main() { int option; do { cout...
My IDE : NETBEAN JAVA THANK YOU SO MUCH ( THE QUESTION IS ON SPECIFICATION) Sample...
My IDE : NETBEAN JAVA THANK YOU SO MUCH ( THE QUESTION IS ON SPECIFICATION) Sample Run Department Store Sales Tax and Grand Total Application Data Entries: Enter 0 to end your input Cost of item: 35.99 Cost of item: 27.50 Cost of item: 19.59 Cost of item: 0 All items total: $83.08 Sales tax rate (%): 6 Promotion code: 123 Discount amount: $1.00 Subtotal: $82.08 Sales tax amount: $4.92 Grand total: $87.00 Continue? y/Y/n/N: y Data Entries: Enter 0...
Having an issue with question C. My answer continues to be incorrect. Thank you. McGriff Dog...
Having an issue with question C. My answer continues to be incorrect. Thank you. McGriff Dog Food Company normally takes 27 days to pay for average daily credit purchases of $9,460. Its average daily sales are $10,700, and it collects accounts in 27 days.      a. What is its net credit position?    b-1. If the firm extends its average payment period from 27 days to 38 days (and all else remains the same), what is the firm's new net...
Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine...
Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine and must break into 2 matrix L and U It must be in MATLAB The code used must use continue statement. If no continue statement is there in code it will be downvoted. Answer only if you know or else i will dislike badly
Can you fix my code and remove the errors? Thank you!! ^^ ////////////////////////////////////////////////////////////////////////////////////////////////////// public class StackException<T,...
Can you fix my code and remove the errors? Thank you!! ^^ ////////////////////////////////////////////////////////////////////////////////////////////////////// public class StackException<T, size> extends Throwable { private final T[] S = null ; public StackException(String s) { } public T top() throws StackException { if (isEmpty()) throw new StackException("Stack is empty."); int top = 0; return S[top]; } private boolean isEmpty() { return false; } public T pop() throws StackException { T item; if (isEmpty()) throw new StackException("Stack underflow."); int top = 0; item = S[top];...
These subquestions are all apart of the same question for my homework! Thank you for your...
These subquestions are all apart of the same question for my homework! Thank you for your help in advance! A) As with most bonds, consider a bond with a face value of $1,000. The bond's maturity is 8 years, the coupon rate is 7% paid annually, and the market yield (discount rate) is 19%. What is the bond's Current Yield? B) What is the price of a bond with the following features? 8 years to maturity, face value of $1000,...
So pretty much I need my code without the arrays, or lists. Please and thank you!...
So pretty much I need my code without the arrays, or lists. Please and thank you! Important: You may not use arrays, lists, or similar for your questions. This will be covered in the next module. The objective is to use conditionals in order to achieve the overall task. Checkpoint 3 is a continuation of the “Quiz” Programming Project. This module week, you will implement repetitive tasks in your program while using conditional and iteration statements in C#. Implement a...
Please based on my python code. do the following steps: thank you Develop a method build_bst...
Please based on my python code. do the following steps: thank you Develop a method build_bst which takes a list of data (example: [6, 2, 4, 22, 34, 9, 6, 67, 42, 55, 70, 120, 99, 200]) and builds a binary search tree full of Node objects appropriately arranged. Test your build_bst with different sets of inputs similar to the example provided above. Show 3 different examples. Choose 1 example data.  Develop a function to remove a node from a bst...
Plaese show all work, thank you You are working on a currency arbitrage desk. You look...
Plaese show all work, thank you You are working on a currency arbitrage desk. You look up exchange rates and interest rates for the USD versus the Canadian Dollar (CAD) and find the following: The current spot rate is 0.810 USD/CAD. The 12-month forward exchange rate is 0.833 USD/CAD (note: Canadian dollar futures contracts are 100,000 CAD each). The 12-month T-bill yield in the USA is 1.31% (assume this is the continuously compounded annualized yield) and the 12-month risk-free rate...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class // instantiates two objects // and prompts the user for infromation about two courses using System; public class DebugSeven1 {     public static void Main()     {         HomeworkAssignment course1;         HomeworkAssignment course2;         string entryString;         int exercises;         // Get info for first class         Console.Write("What class do you have homework for? ");         entryString = Console.ReadLine(); // Fixed .ReadLine         course1.ClassName...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT