Question

use mathematica Find number a, a is positive integer and a<2000, such that f(n) =n^2-79n +a...

use mathematica

Find number a, a is positive integer and a<2000, such that f(n) =n^2-79n +a is prime numbers for all n on [0,79]
please include your code input and output in the answers.

Homework Answers

Answer #1

so as no language is specified so we will solve this problem in c++ together

as the problem is not very clear that how many values need to print so I am writing generic code that will give an answer for all n

So are u with me on this........let's do it

here is the code

// Find number a, a is positive integer and a<2000, such that f(n) =n^2-79n +a is prime numbers for all n on [0,79]
// please include your code input and output in the answers.

#include <bits/stdc++.h>
using namespace std;
int main()
{
// so we have a range of n from [0,79]
// range of a is up to a< 2000
int n = 80;
// all prime number from a 0 to 2000 so that it can be easy to solve it later
//so there can many values of a, when when we add it to n^2 - 79n so I will print all the numbers
vector<int>res; // vector created to store all the prime numbers
  
res.push_back(2); // push_back is used to append the value in the vector
  
// this code is for find all the prime number time compexity for this code to find all prime number is O(nlong(n))
for(int i =3;i<2000;i++){
int flag = 0;
for(int j = 2;j*j<=i;j++){
if(i%j==0){
flag = 1;
}
}
if(flag ==0){
res.push_back(i);
}
}
cout<<" prime numbers are :"<<endl; //prints all the prime numbers
for(int i = 0;i<res.size();i++){
cout<<res[i]<<" ";
}
cout<<endl;
vector<pair<int,int>>ans; // making a pair to find for which value of n what are the values of a that are prime
  
// code to find all the (a) value
for(int i = 0;i<n;i++)
{
// f(n) = n^2-79n+a
for(int j= 0;j<2000;j++){ // runs for a value
int check_val = i*i -79*i +j;
if(find(res.begin(), res.end(), check_val) != res.end()) // find if the check_val is res or not if yes then we got our a value
ans.push_back({i,j});
}
}
  
cout<<"\nvalue of a when added to f(n) makes it prime for what value of n\n"<<endl;
//ans[i].first = value of n
//ans[i].second = value of a
for(int i = 0;i<ans.size();i++){
cout<<"[ "<<ans[i].first<<" "<<ans[i].second<<" ]"<<" " ;// prints n value then a value when added to function makes it prime.
}

return 0;
}

output file for this is

if any doubt, comment below.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Collapse Write a program that prompts the user to input a positive integer. It should then...
Collapse Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd integer is prime if it is not divisible by any odd integer less than or equal to the square root of the number.) Turn in: Your source code for with The name of your program as a comment at the top...
For C++: a) Write a function is_prime that takes a positive integer X and returns 1...
For C++: a) Write a function is_prime that takes a positive integer X and returns 1 if X is a prime number, or 1 if X is not a prime number. b) write a program that takes a positive integer N and prints all prime numbers from 2 to N by calling your function is_prime from part a.
/* This program should check if the given integer number is prime. Reminder, an integer number...
/* This program should check if the given integer number is prime. Reminder, an integer number greater than 1 is prime if it divisible only by itself and by 1. In other words a prime number divided by any other natural number (besides 1 and itself) will have a non-zero remainder. Your task: Write a method called checkPrime(n) that will take an integer greater than 1 as an input, and return true if that integer is prime; otherwise, it should...
In R- Studio : Write a function that takes as an input a positive integer and...
In R- Studio : Write a function that takes as an input a positive integer and uses the print() function to print out all the numbers less than the input integer. (Example: for input 5, the function should print the numbers 1,2,3,4 { for input 1, the function should not print a number.) Write a recursive function, do not use any of the loop commands in your code.
Euler's Totient Function Let f(n) denote Euler's totient function; thus, for a positive integer n, f(n)...
Euler's Totient Function Let f(n) denote Euler's totient function; thus, for a positive integer n, f(n) is the number of integers less than n which are coprime to n. For a prime p its is known that f(p^k) = p^k-p^{k-1}. For example f(27) = f(3^3) = 3^3 - 3^2 = (3^2) 2=18. In addition, it is known that f(n) is multiplicative in the sense that f(ab) = f(a)f(b) whenever a and b are coprime. Lastly, one has the celebrated generalization...
Let a positive integer n be called a super exponential number if its prime factorization contains...
Let a positive integer n be called a super exponential number if its prime factorization contains at least one prime to a power of 1000 or larger. Prove or disprove the following statement: There exist two consecutive super exponential numbers.
In this problem your task is to find a missing number. The input will always consist...
In this problem your task is to find a missing number. The input will always consist of an array of n positive integers such that the difference between every two consecutive numbers is a fixed constant but one integer is missing. See below for two example inputs/outputs: Input sequence: [0, 2, 4, 6, 10] Output: missing number is 8 Input sequence: [1, 4, 7, 13, 16] Output: missing number is 10 Note that in the first example the constant c...
An integer 'n' greater than 1 is prime if its only positive divisor is 1 or...
An integer 'n' greater than 1 is prime if its only positive divisor is 1 or itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not. Write a python program that defines a function isPrime (number) with the following header: def isPrime (number): that checks whether a number is prime or not. Use that function in your main program to count the number of prime numbers that are less than 5000....
let's fix a positive integer n. for a nonnegative integer k, let ak be the number...
let's fix a positive integer n. for a nonnegative integer k, let ak be the number of ways to distribute k indistinguishable balls into n distinguishable bins so that an even number of balls are placed in each bin (allowing empty bins). The generating function for sequence ak is given as 1/F(x). Find F(x).
4) Let F be a finite field. Prove that there exists an integer n ≥ 1,...
4) Let F be a finite field. Prove that there exists an integer n ≥ 1, such that n.1F = 0F . Show further that the smallest positive integer with this property is a prime number.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT