Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Problem 17

5 comments on “Problem 17”


  • Sadique Gametor

    #include
    int prime(int n)
    {
    int i,c=0;
    for(i=1;i<=n;i++)
    {
    if(n%i==0)
    c++;
    }
    if(c==2)
    return 1;
    else
    return 0;
    }
    int main()
    {
    int x,i,q,a[100],j,sum=0,l;
    scanf("%d",&l);
    scanf("%d",&x);
    q=0;
    for(i=l;i<=x;i++)
    {
    if(prime(i))
    {
    a[q]=i;
    q++;
    }
    }
    for(i=0;i<q;i++)
    {
    sum=sum+a[i];
    }
    printf("%d",sum);
    return 0;
    }


  • avi gehlot

    #Sum of odd number in given range
    a,b=map(int, input().split(” “))
    sum=0
    for i in range(a,b+1):
    if (i%2!=0):
    sum =sum+ i
    print(“sum of odd number is:”,sum)


  • Mohd Saif

    #python

    n1,n2=map(int,input().split(” “))
    x=0
    for i in range(n1,n2+1):
    if(i%2!=0):
    x=x+i
    print(f”sum of odd number between {n1} and {n2} is:{x}”)


  • PARTHA SARATHI SINHA

    #include
    int main()
    {
    int sum=0,i,max;
    scanf(“%d”,&max);
    for(i=0;i<max;i++)
    {
    if(i%2!=0)
    {
    sum=sum+i;
    }
    }
    printf("%d",sum);
    return 0;

    }