బహుళ భాషలను ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని ఎలా కనుగొనాలి

బహుళ భాషలను ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని ఎలా కనుగొనాలి

మీ ప్రోగ్రామింగ్ నైపుణ్యాలను మెరుగుపరచడానికి చూస్తున్నప్పుడు, మీరు బహుశా ఏదో ఒక సమయంలో రేఖాగణిత సన్నివేశాల గురించి తెలుసుకోవాలనుకుంటారు. రేఖాగణిత క్రమంలో, ప్రతి పదం మునుపటి పదాన్ని స్థిరాంకం ద్వారా గుణించడం ద్వారా కనుగొనబడుతుంది.





ఈ వ్యాసంలో, పైథాన్, సి ++, జావాస్క్రిప్ట్ మరియు సి ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని ఎలా కనుగొనాలో మీరు నేర్చుకుంటారు.





రేఖాగణిత సిరీస్ అంటే ఏమిటి?

అనంతమైన రేఖాగణిత క్రమం యొక్క నిబంధనల మొత్తాన్ని రేఖాగణిత శ్రేణి అంటారు. రేఖాగణిత క్రమం లేదా రేఖాగణిత పురోగతి క్రింది విధంగా సూచించబడుతుంది:





టాస్క్‌బార్ విండోస్ 10 లో ఏదైనా క్లిక్ చేయడం సాధ్యపడదు
a, ar, ar², ar³, ...

ఎక్కడ,

a = First term
r = Common ratio

సమస్యల నివేదిక

మీకు మొదటి పదం, సాధారణ నిష్పత్తి మరియు సంఖ్య ఇవ్వబడింది. రేఖాగణిత శ్రేణి నిబంధనలు. మీరు రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనాలి. ఉదాహరణ : ముందుగా టెర్మ్ = 1, కామన్ రేషియో = 2, మరియు noOfTerms = 8. రేఖాగణిత శ్రేణి: 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 రేఖాగణిత శ్రేణి మొత్తం: 255 కాబట్టి, అవుట్‌పుట్ 255.



రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి పునరావృత విధానం

ముందుగా, రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి పునరావృత మార్గాన్ని చూద్దాం. దిగువ ప్రతి ప్రధాన ప్రోగ్రామింగ్ భాషతో దీన్ని ఎలా చేయాలో మీరు కనుగొంటారు.

సి ++ ప్రోగ్రామ్ ఇట్రేషన్ ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడం

పునరావృతాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి C ++ ప్రోగ్రామ్ క్రింద ఉంది:





// C++ program to find the sum of geometric series
#include
using namespace std;
// Function to find the sum of geometric series
float sumOfGeometricSeries(float firstTerm, float commonRatio, int noOfTerms)
{
float result = 0;
for (int i=0; i {
result = result + firstTerm;
firstTerm = firstTerm * commonRatio;
}
return result;
}
int main()
{
float firstTerm = 1;
float commonRatio = 2;
int noOfTerms = 8;
cout << 'First Term: ' << firstTerm << endl;
cout << 'Common Ratio: ' << commonRatio << endl;
cout << 'Number of Terms: ' << noOfTerms << endl;
cout << 'Sum of the geometric series: ' << sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms) << endl;
return 0;
}

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

ఇట్రేషన్ ఉపయోగించి జ్యామెట్రిక్ సిరీస్ మొత్తాన్ని కనుగొనడానికి పైథాన్ ప్రోగ్రామ్

పునరావృతాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి పైథాన్ ప్రోగ్రామ్ క్రింద ఉంది:





# Python program to find the sum of geometric series
# Function to find the sum of geometric series
def sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms):
result = 0
for i in range(noOfTerms):
result = result + firstTerm
firstTerm = firstTerm * commonRatio
return result
firstTerm = 1
commonRatio = 2
noOfTerms = 8
print('First Term:', firstTerm)
print('Common Ratio:', commonRatio)
print('Number of Terms:', noOfTerms)
print('Sum of the geometric series:', sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms))

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

సంబంధిత: 'హలో, వరల్డ్!' అత్యంత ప్రాచుర్యం పొందిన ప్రోగ్రామింగ్ భాషలలో

జాటస్క్రిప్ట్ ప్రోగ్రామ్ ఇట్రేషన్ ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి

పునరుక్తిని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి జావాస్క్రిప్ట్ ప్రోగ్రామ్ క్రింద ఉంది:

// JavaScript program to find the sum of geometric series
// Function to find the sum of geometric series
function sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms) {
var result = 0;
for (let i=0; i {
result = result + firstTerm;
firstTerm = firstTerm * commonRatio;
}
return result;
}

var firstTerm = 1;
var commonRatio = 2;
var noOfTerms = 8;
document.write('First Term: ' + firstTerm + '
');
document.write('Common Ratio: ' + commonRatio + '
');
document.write('Number of Terms: ' + noOfTerms + '
');
document.write('Sum of the geometric series: ' + sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms));

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

ఇట్రేషన్ ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి సి ప్రోగ్రామ్

పునరావృతాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి C ప్రోగ్రామ్ క్రింద ఉంది:

// C program to find the sum of geometric series
#include
// Function to find the sum of geometric series
float sumOfGeometricSeries(float firstTerm, float commonRatio, int noOfTerms)
{
float result = 0;
for (int i=0; i {
result = result + firstTerm;
firstTerm = firstTerm * commonRatio;
}
return result;
}
int main()
{
float firstTerm = 1;
float commonRatio = 2;
int noOfTerms = 8;
printf('First Term: %f ⁠n', firstTerm);
printf('Common Ratio: %f ⁠n', commonRatio);
printf('Number of Terms: %d ⁠n', noOfTerms);
printf('Sum of the geometric series: %f ⁠n', sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms));
return 0;
}

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

ఫార్ములా ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి సమర్థవంతమైన విధానం

రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి మీరు క్రింది సూత్రాన్ని ఉపయోగించవచ్చు:

Sum of geometric series = a(1 – rn)/(1 – r)

ఎక్కడ,

a = First term
d = Common ratio
n = No. of terms

ఫార్ములా ఉపయోగించి జ్యామితీయ శ్రేణి మొత్తాన్ని కనుగొనడానికి C ++ ప్రోగ్రామ్

సూత్రాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి C ++ ప్రోగ్రామ్ క్రింద ఉంది:

// C++ program to find the sum of geometric series
#include
using namespace std;
// Function to find the sum of geometric series
float sumOfGeometricSeries(float firstTerm, float commonRatio, int noOfTerms)
{
return (firstTerm * (1 - pow(commonRatio, noOfTerms))) / (1 - commonRatio);
}
int main()
{
float firstTerm = 1;
float commonRatio = 2;
int noOfTerms = 8;
cout << 'First Term: ' << firstTerm << endl;
cout << 'Common Ratio: ' << commonRatio << endl;
cout << 'Number of Terms: ' << noOfTerms << endl;
cout << 'Sum of the geometric series: ' << sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms) << endl;
return 0;
}

అవుట్‌పుట్:

స్నాప్‌చాట్‌లో ఫిల్టర్‌ను ఎలా ఉపయోగించాలి
First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

సూత్రాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి పైథాన్ ప్రోగ్రామ్

సూత్రాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి పైథాన్ ప్రోగ్రామ్ క్రింద ఉంది:

# Python program to find the sum of geometric series
# Function to find the sum of geometric series
def sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms):
return (firstTerm * (1 - pow(commonRatio, noOfTerms))) / (1 - commonRatio)
firstTerm = 1
commonRatio = 2
noOfTerms = 8
print('First Term:', firstTerm)
print('Common Ratio:', commonRatio)
print('Number of Terms:', noOfTerms)
print('Sum of the geometric series:', sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms))

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

సంబంధిత: బహుళ భాషలలో రెండు సంఖ్యల LCM మరియు GCD ని ఎలా కనుగొనాలి

టెరాబైట్ ఎంత మెమరీ

ఫార్ములా ఉపయోగించి జ్యామెట్రిక్ సిరీస్ మొత్తాన్ని కనుగొనడానికి జావాస్క్రిప్ట్ ప్రోగ్రామ్

సూత్రాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి జావాస్క్రిప్ట్ ప్రోగ్రామ్ క్రింద ఉంది:

// JavaScript program to find the sum of geometric series
// Function to find the sum of geometric series
function sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms) {
return (firstTerm * (1 - Math.pow(commonRatio, noOfTerms))) / (1 - commonRatio);
}

var firstTerm = 1;
var commonRatio = 2;
var noOfTerms = 8;
document.write('First Term: ' + firstTerm + '
');
document.write('Common Ratio: ' + commonRatio + '
');
document.write('Number of Terms: ' + noOfTerms + '
');
document.write('Sum of the geometric series: ' + sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms));

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

సంబంధిత: స్ట్రింగ్‌లో ఇచ్చిన పాత్ర యొక్క సంఘటనలను ఎలా లెక్కించాలి

సి ఫార్ములా ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి ప్రోగ్రామ్

సూత్రాన్ని ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని కనుగొనడానికి C ప్రోగ్రామ్ క్రింద ఉంది:

// C program to find the sum of geometric series
#include
#include
// Function to find the sum of geometric series
float sumOfGeometricSeries(float firstTerm, float commonRatio, int noOfTerms)
{
return (firstTerm * (1 - pow(commonRatio, noOfTerms))) / (1 - commonRatio);
}
int main()
{
float firstTerm = 1;
float commonRatio = 2;
int noOfTerms = 8;
printf('First Term: %f ⁠n', firstTerm);
printf('Common Ratio: %f ⁠n', commonRatio);
printf('Number of Terms: %d ⁠n', noOfTerms);
printf('Sum of the geometric series: %f ⁠n', sumOfGeometricSeries(firstTerm, commonRatio, noOfTerms));
return 0;
}

అవుట్‌పుట్:

First Term: 1
Common Ratio: 2
Number of Terms: 8
Sum of the geometric series: 255

వివిధ ప్రోగ్రామింగ్ లాంగ్వేజ్‌లను ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాలను ఎలా కనుగొనాలో ఇప్పుడు మీకు తెలుసు

ఈ ఆర్టికల్లో, రెండు విధానాలను ఉపయోగించి రేఖాగణిత శ్రేణి మొత్తాన్ని ఎలా కనుగొనాలో మీరు నేర్చుకున్నారు: పునరావృతం మరియు ఫార్ములా. పైథాన్, సి ++, జావాస్క్రిప్ట్ మరియు సి వంటి వివిధ ప్రోగ్రామింగ్ భాషలను ఉపయోగించి ఈ సమస్యను ఎలా పరిష్కరించాలో కూడా మీరు నేర్చుకున్నారు.

పైథాన్ అనేది కోడ్-రీడబిలిటీపై దృష్టి సారించే సాధారణ-ప్రయోజన ప్రోగ్రామింగ్ భాష. మీరు డేటా సైన్స్, మెషిన్ లెర్నింగ్, వెబ్ డెవలప్‌మెంట్, ఇమేజ్ ప్రాసెసింగ్, కంప్యూటర్ విజన్ మొదలైన వాటి కోసం పైథాన్‌ను ఉపయోగించవచ్చు. ఇది చాలా బహుముఖ ప్రోగ్రామింగ్ భాషలలో ఒకటి. ఈ శక్తివంతమైన ప్రోగ్రామింగ్ భాషను అన్వేషించడం చాలా విలువైనది.

షేర్ చేయండి షేర్ చేయండి ట్వీట్ ఇమెయిల్ ఇమెయిల్ నిజమైనదా లేదా నకిలీదా అని తనిఖీ చేయడానికి 3 మార్గాలు

మీరు కొంచెం సందేహాస్పదంగా ఉన్న ఇమెయిల్‌ను అందుకున్నట్లయితే, దాని ప్రామాణికతను తనిఖీ చేయడం ఎల్లప్పుడూ ఉత్తమం. ఇమెయిల్ నిజమో కాదో చెప్పడానికి ఇక్కడ మూడు మార్గాలు ఉన్నాయి.

తదుపరి చదవండి
సంబంధిత అంశాలు
  • ప్రోగ్రామింగ్
  • పైథాన్
  • జావాస్క్రిప్ట్
  • సి ప్రోగ్రామింగ్
  • ప్రోగ్రామింగ్
రచయిత గురుంచి యువరాజ్ చంద్ర(60 కథనాలు ప్రచురించబడ్డాయి)

యువరాజ్ భారతదేశంలోని ఢిల్లీ విశ్వవిద్యాలయంలో కంప్యూటర్ సైన్స్ అండర్ గ్రాడ్యుయేట్ విద్యార్థి. అతను పూర్తి స్టాక్ వెబ్ డెవలప్‌మెంట్ పట్ల మక్కువ కలిగి ఉన్నాడు. అతను వ్రాయనప్పుడు, అతను వివిధ సాంకేతికతల లోతును అన్వేషిస్తున్నాడు.

యువరాజ్ చంద్ర నుండి మరిన్ని

మా వార్తాలేఖకు సభ్యత్వాన్ని పొందండి

టెక్ చిట్కాలు, సమీక్షలు, ఉచిత ఈబుక్‌లు మరియు ప్రత్యేకమైన డీల్స్ కోసం మా వార్తాలేఖలో చేరండి!

సభ్యత్వం పొందడానికి ఇక్కడ క్లిక్ చేయండి