Help me in solving DIFACTRS problem why i am facing run time error

My issue

My code

#include <stdio.h>

int main() {
	int x,c=0;
	scanf("%d",&x);
	for(int i=0;i<x;i++){
	   if(x%i==0){
	       c++;
	    
	}
	}printf("%d ",c);
	for(int i=0;i<x;i++){
	    if(x%i==0){
	        printf("%d ",i);
	    }
	}
	return 0;
}


Problem Link: CodeChef: Practical coding for everyone

@ronak122
u r getting runtime error because u r looping from i=0 and when u check x%i for i==0 it will give run time error so check it from i=1 then it will work fine.

yes thanks i have understand my mistake and
congratulations for 4star

1 Like