Submit | All submissions | Best solutions | Back to list |
APS - Amazing Prime Sequence |
Bablu is very fond of Series and Sequences...
After studying Fibonacci Series in Class IX, he was impressed and he designed his own sequence as follows...
a[0] = a[1] = 0
For n > 1, a[n] = a[n - 1] + f(n), where f(n) is smallest prime factor of n.
He is also very fond of programming and thus made a small program to find a[n], but since he is in Class IX, he is not very good at programming. So, he asks you for help. Your task is to find a[n] for the above sequence....
Input
Your code will be checked for multiple test cases.
First line of Input contains T (≤ 100), the number of test cases.
Next T lines contain a single number N. (1 < N < 107).
Output
Single line containing a[n] i.e. nth number of the sequence for each test case.
Example
Input: 3 2 3 4 Output: 2 5 7
Added by: | c[R]@zY f[R]0G |
Date: | 2013-02-14 |
Time limit: | 1s |
Source limit: | 5000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
||||||||||
2015-06-11 06:59:42 jammi
Can you please verify my submission with id-14432517. |
||||||||||
2015-06-08 05:36:34 ---@@@----
Accepted after lot of TLE's... Last edit: 2015-06-08 05:37:02 |
||||||||||
2015-06-03 05:37:35 [Mayank Pratap]
Nice for beginners like me!!! |
||||||||||
2015-06-02 14:24:40 NEXES
Some Change in the Sheive and got ac!!!! |
||||||||||
2015-05-21 10:58:32 kartikay singh
AC in 1 go:) BRUTE FORCE (y) |
||||||||||
2015-05-03 17:00:26 happy
accepted in one go!!! |
||||||||||
2015-04-14 11:49:14 Madhav
done!! |
||||||||||
2015-04-11 20:29:49 krish
brute force only:) |
||||||||||
2014-03-21 18:08:10 free mind ;)
nice one :) |
||||||||||
2014-01-02 10:21:04 Sameer
@Prakhar Gupta : Make it global or static :) |