Download 1B.py from Madhan-Alagarsamy/Python: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/datasets/Madhan-Alagarsamy/Python/resolve/main/1B.py
- Command line
-
hf download hf://datasets/Madhan-Alagarsamy/Python/1B.py
-
curl -L -o 1B.py https://huggingface.co/datasets/Madhan-Alagarsamy/Python/resolve/main/1B.py
717 Bytes
| def binary_sum(S, start, stop): | |
| if start>=stop: | |
| return 0 | |
| elif start == stop-1: | |
| return S[start] | |
| else: | |
| mid= (start+stop)//2 | |
| return binary_sum(S, start, mid)+binary_sum(S, mid,stop) | |
| print("\t summing the elements of a sequence using binary recursion") | |
| print("\t -----------------------------------------") | |
| S=[] | |
| print("Input") | |
| print("- - - - -") | |
| n=int(input("enter the no of elements:")) | |
| print("Enter the elements one by one:") | |
| for i in range(n): | |
| m=int(input()) | |
| S.append(m) | |
| print("The given sequence of elements=",S) | |
| r=binary_sum(S, 0, n) | |
| print("output") | |
| print("- - - - - -") | |
| print("The given sum of sequence of elements=",r) |